
#include <iostream>
using namespace std;
struct R{
int bx,by,x,y;
char to;
};
R f={0,0,0,0,'B'},c={0,0,0,0,'B'};
char map[11][11];
int ans=0,vis[12][12][12][12];
void move(R r){
if(r.to=='B'&&map[r.x-1][r.y]!='*') r.x-=1;
else if(r.to=='B'&&map[r.x-1][r.y]=='*') r.to='D';
else if(r.to=='D'&&map[r.x][r.y+1]!='*') r.y+=1;
else if(r.to=='D'&&map[r.x][r.y+1]=='*') r.to='N';
else if(r.to=='N'&&map[r.x+1][r.y]!='*') r.x+=1;
else if(r.to=='N'&&map[r.x+1][r.y]=='*') r.to='X';
else if(r.to=='X'&&map[r.x][r.y-1]!='*') r.y-=1;
else r.to='B';
}
int main(){
for(int i=0;i<=11;i++)
for(int j=0;j<=11;j++){
if(i==0||i==11||j==0||j==11){
map[i][j]='*';
continue;
}
cin>>map[i][j];
if(map[i][j]=='C'){
c.bx=c.x=i;
c.by=c.y=j;
map[i][j]='.';
}
if(map[i][j]=='F'){
f.bx=f.x=i;
f.by=f.y=j;
map[i][j]='.';
}
}
while(c.x==f.x&&c.y==f.y){
if(vis[c.x][c.y][f.x][f.y]){
cout<<0;
return 0;
}
vis[c.x][c.y][f.x][f.y]=1;
move(c);
move(f);
ans++;
}
cout<<ans;
return 0;
}