#include <iostream>
using namespace std;
char c[12][12];
int dir[4][2] = {{-1,0}, {0,1}, {1,0}, {0,-1}};
int main() {
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
c[i][j] = '*';
int x1, y1, x2, y2;
int w1 = 0, w2 = 0;
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
c[i][j] = getchar();
if (c[i][j] == 'C') {
x1 = i;
y1 = j;
c[i][j] = '.';
} else if (c[i][j] == 'F') {
x2 = i;
y2 = j;
c[i][j] = '.';
}
}
getchar();
}
for (int ans = 1; ans <= 1000000; ans++) {
int nx = x1 + dir[w1][0];
int ny = y1 + dir[w1][1];
if (c[nx][ny] == '*') {
w1 = (w1 + 1) % 4;
} else {
x1 = nx;
y1 = ny;
}
nx = x2 + dir[w2][0];
ny = y2 + dir[w2][1];
if (c[nx][ny] == '*') {
w2 = (w2 + 1) % 4;
} else {
x2 = nx;
y2 = ny;
}
if (x1 == x2 && y1 == y2) {
cout << ans << endl;
return 0;
}
}
cout << 0 << endl;
return 0;
}