#include <bits/stdc++.h>
using namespace std;
int a[15][15];
int ans = 44;
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
void bfs(int x, int y)
{
for (int i = 0; i < 4; i++)
{
int xx = x + dir[i][0];
int yy = y + dir[i][1];
if (xx >= 0 && xx <= 11 && yy >= 0 && yy <= 11)
if (a[xx][yy] == 0)
{
a[xx][yy] = 1;
ans--;
bfs(xx, yy);
}
}
}
int main()
{
for (int i = 1; i <= 10; i++)
for (int j = 1; j <= 10; j++)
{
cin >> a[i][j];
if (a[i][j] == 0)
ans++;
}
a[0][0] = 1;
ans--;
bfs(0, 0);
cout << ans;
return 0;
}