#include <bits/stdc++.h>
using namespace std;
int vec[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
struct pos {
int x, y;
pos(int i, int j) {
x = i, y = j;
}
pos() {
x = y = 0;
}
};
int main () {
bool matrix[10][10], vst[10][10];
int cnt1 = 0;
int sx = 0, sy = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
vst[i][j] = 0;
cin >> matrix[i][j];
if (matrix[i][j] == 1) {
cnt1++;
} else {
sx = i, sy = j;
}
}
}
pos st(sx, sy);
queue<pos> q;
bool flag = 1;
q.push(st);
int ct = 0;
vst[sx][sy] = 1;
while (!q.empty()) {
pos nowat = q.front();
q.pop();
// cout << nowat.x << ' ' << nowat.y << endl;
ct++;
for (int i = 0; i < 4; i++) {
if (nowat.x + vec[i][0] < 0 || nowat.y + vec[i][1] < 0 || nowat.x + vec[i][0] >= 10 || nowat.y + vec[i][1] >= 10) {
flag = 0;
} else {
if (vst[nowat.x + vec[i][0]][nowat.y + vec[i][1]] == 0 && matrix[nowat.x + vec[i][0]][nowat.y + vec[i][1]] == 0) {
pos t(nowat.x + vec[i][0], nowat.y + vec[i][1]);
vst[t.x][t.y] = 1;
q.push(t);
}
}
}
}
// cout << st.x << ' ' << st.y << endl;
if (flag) {
cout << ct;
} else {
cout << 100 - ct - cnt1;
}
return 0;
}