#include<stdio.h>
#include<string.h>
int main()
{
char map[10][10];
int cx=0,cy=0,fx=0,fy=0;
for(int i=0;i<10;i++){
fgets(map[i],100,stdin);
map[i][strcspn(map[i],"\n")]=0;
}
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(map[i][j]=='C'){
cx=j;
cy=i;
}
if(map[i][j]=='F'){
fx=j;
fy=i;
}
}
}
int cnt=0,cp=0,fp=0;//cp,fp->direct
while(1){
switch(cp){
case 0:if(map[cy-1][cx]=='*'||cy-1<0){
cp=(cp+1)%4;
}else{
cy--;
}
case 1:if(map[cy][cx+1]=='*'||cx+1>9){
cp=(cp+1)%4;
}else{
cx++;
}
case 2:if(map[cy+1][cx]=='*'||cy+1>9){
cp=(cp+1)%4;
}else{
cy++;
}
case 3:if(map[cy][cx-1]=='*'||cx-1<0){
cp=(cp+1)%4;
}else{
cx--;
}
}
switch(fp){
case 0:if(map[fy-1][fx]=='*'||fy-1<0){
fp=(fp+1)%4;
}else{
fy--;
}
case 1:if(map[fy][fx+1]=='*'||fx+1>9){
fp=(fp+1)%4;
}else{
fx++;
}
case 2:if(map[fy+1][fx]=='*'||fy+1>9){
fp=(fp+1)%4;
}else{
fy++;
}
case 3:if(map[fy][fx-1]=='*'||fx-1<0){
fp=(fp+1)%4;
}else{
fx--;
}
}
cnt++;
if(cx==fx&&fy==cy||cnt==160000) break;
}
if(cnt<160000){
printf("%d",cnt);
}else printf("0");
return 0;
}