#include<stdio.h>
int main(){
char a[13][13]={},ch;
int n1=1,n2=1,t=0;
int C_p1=0,C_p2=0,F_p1=0,F_p2=0,Label_c=1,Label_f=1;
for(n1=1;n1<=10;n1++){
for(n2=1;n2<=10;n2++){
while((ch=getchar())=='\n'||ch==' ')continue;
a[n1][n2]=ch;
if(a[n1][n2]=='C'){C_p1=n1;C_p2=n2;}
if(a[n1][n2]=='F'){F_p1=n1;F_p2=n2;}
}
}
getchar();getchar();
for(t=0;(C_p1!=F_p1||C_p2!=F_p2);){
t++;
if(a[C_p1-1][C_p2]!='*'&&C_p1-1 != 0&&Label_c==1)C_p1--;
else if(Label_c==1) Label_c=2;
else if(a[C_p1][C_p2+1]!='*'&&C_p2+1!=11&&Label_c==2)C_p2++;
else if(Label_c==2) Label_c=3;
else if(a[C_p1+1][C_p2]!='*'&&C_p1+1!=11&&Label_c==3) C_p1++;
else if(Label_c==3) Label_c = 4;
else if(a[C_p1][C_p2-1]!='*'&&C_p2-1!=0&&Label_c==4)C_p2--;
else if(Label_c==4) Label_c = 1;
if(a[F_p1-1][F_p2]!='*'&&F_p1-1 != 0&&Label_f==1)F_p1--;
else if(Label_f==1) Label_f=2;
else if(a[F_p1][F_p2+1]!='*'&&F_p2+1!=11&&Label_f==2)F_p2++;
else if(Label_f==2) Label_f=3;
else if(a[F_p1+1][F_p2]!='*'&&F_p1+1!=11&&Label_f==3) F_p1++;
else if(Label_f==3) Label_f = 4;
else if(a[F_p1][F_p2-1]!='*'&&F_p2-1!=0&&Label_f==4)F_p2--;
else if(Label_f==4) Label_f = 1;
if(C_p1==F_p1&&C_p2==F_p2)break;
if(t>=2000)break;
}
if(t>=2000)t=0;
printf("%d",t);
}