#include<bits/stdc++.h>
using namespace std;
char a[15][15];
int runx[4] = {-1,0,1,0};
int runy[4] = {0,1,0,-1};
int main(){
for(int i = 0;i<=11;i++){
for(int j = 0;j<=11;j++){
a[i][j] = '*';
}
}
int jx,jy,jmove_plan = 0;
int cx,cy,cmove_plan = 0;
int res = 0;
for(int i = 1;i<=10;i++){
for(int j = 1;j<=10;j++){
a[i][j] = getchar();
if(a[i][j] == 'F'){
jx = i;
jy = j;
a[i][j] = '.';
}
if(a[i][j] == 'C'){
cx = i;
cy = j;
a[i][j] = '.';
}
}
getchar();
}
while(jx != cx||jy != cy){
if(res>=1000000){
cout<<0;
return 0;
}
int nowjx = jx+runx[jmove_plan],nowjy = jy+runy[jmove_plan];
int nowcx = cx+runx[cmove_plan],nowcy = cy+runy[cmove_plan];
if(a[nowjx][nowjy]!='.'){
jmove_plan++;
jmove_plan%=4;
}else{
jx = nowjx;
jy = nowjy;
}
if(a[nowcx][nowcy]!='.'){
cmove_plan++;
cmove_plan%=4;
}else{
cx = nowcx;
cy = nowcy;
}
res++;
}
cout<<res;
return 0;
}