#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int stx, sty, px, py;
bool v[10][10][10][10][5][5];
char a[50][50];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
void func1() {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (a[i][j] == 'C') {
px = i, py = j;
}
else if (a[i][j] == 'F') {
stx = i, sty = j;
}
}
}
}
int check(int x,int y) {
if (x >= 0 && y >= 0 && a[x][y] != '*' && x < 10 && y < 10)return 1;
return 0;
}
int main() {
int ans = 0;
for (int i = 0; i < 10; i++) {
cin >> a[i];
}
func1();
int tx = 0, ty = 0, k1 = 0, k2 = 0;
while (1) {
if (stx == px && sty == py) {
cout << ans << endl;
return 0;
}
if (v[stx][sty][px][py][tx][ty])
{
printf("0");
return 0;
}
v[stx][sty][px][py][tx][ty] = 1;
if (check(stx + dx[tx], sty + dy[tx])==0)
tx = (tx + 1) % 4;
else
stx += dx[tx], sty += dy[tx];
if (check(px + dx[ty], py + dy[ty])==0)
ty = (ty + 1) % 4;
else
px += dx[ty], py += dy[ty];
ans++;
}
}