#include<iostream>
#include<vector>
#include<queue>
using namespace std;
struct DIR{
int x,y;
}dir;
queue<DIR> quman,qucow;
char mp[15][15];
int main(){
int x=-1,y=0;
quman.push({x,y});
qucow.push({x,y});
x=0,y=1;
quman.push({x,y});
qucow.push({x,y});
x=1,y=0;
quman.push({x,y});
qucow.push({x,y});
x=0,y=-1;
quman.push({x,y});
qucow.push({x,y});
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin>>mp[i][j];
}
}
int cowx,cowy,perx,pery;
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
if(mp[i][j]=='F'){
perx=i; pery=j;
}
if(mp[i][j]=='C'){
cowx=i; cowy=j;
}
}
}
int time=0;
while(!(perx==cowx&&pery==cowy)){
int tx=perx+quman.front().x;
int ty=pery+quman.front().y;
while(mp[tx][ty]=='*'||tx<1||ty<1||tx>10||ty>10){
int xx=quman.front().x;
int yy=quman.front().y;
quman.pop();
quman.push({xx,yy});
tx=perx+quman.front().x;
ty=pery+quman.front().y;
}
perx=tx; pery=ty;
int dx=cowx+qucow.front().x;
int dy=cowy+qucow.front().y;
while(mp[dx][dy]=='*'||dx<1||dy<1||dx>10||dy>10){
int xx=qucow.front().x;
int yy=qucow.front().y;
qucow.pop();
qucow.push({xx,yy});
dx=cowx+qucow.front().x;
dy=cowy+qucow.front().y;
}
cowx=dx; cowy=dy;
time++;
if(time>1000000){
cout<<0;
return 0;
}
}
cout<<time;
return 0;
}