#include<iostream>
#include<cstring>
using namespace std;
bool map[11][11];
struct pos{
int x,y;
int dire;
};
int dx[5]={0,0,1,0,-1};
int dy[5]={0,1,0,-1,0};
pos cow,farmer;
pos first_cow,first_farmer;
bool equal_(pos a,pos b){
if(a.dire==b.dire&&a.x==b.x&&a.y==b.y) return true;
else return false;
}
void check_dire(pos *k){
int nowx=k->x+dx[k->dire];
int nowy=k->y+dy[k->dire];
if(nowx<=0||nowy<=0||nowx>10||nowy>10||map[nowx][nowy]==0)
k->dire=(k->dire-1)%4+1;
else{
k->x=nowx;
k->y=nowy;
}
}
void search(int time){
if(cow.x==farmer.x&&cow.y==farmer.y){
cout<<time;
return;
}
check_dire(&cow);
check_dire(&farmer);
search(time+1);
return;
}
int main(){
memset(map,1,sizeof(map));
char c;
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin>>c;
switch(c){
case '*':
map[i][j]=0;break;
case '.':
case 'C':
cow.dire=1;cow.x=i;cow.y=j;break;
case 'F':
farmer.dire=1;farmer.x=i;farmer.y=j;break;
}
}
}
first_cow=cow;
first_farmer=farmer;
search(0);
system("pause");
return 0;
}