#include<iostream>
#include<string.h>
using namespace std;
char map[12][12];
struct man{
int flag;
int x;
int y;
};man cow,farm;
void move(man *p){
if (p->flag == 0) {
if ((map[p->x - 1][p->y]) == '*') {
p->flag == 1;
}
else p->x--;
}
else if (p->flag == 1) {
if (map[p->x][p->y + 1] == '*') {
p->flag == 2;
}
else p->y++;
}
else if (p->flag == 2) {
if (map[p->x + 1][p->y] == '*') {
p->flag == 3;
}
else p->x++;
}
else if (p->flag == 3) {
if (map[p->x][p->y - 1] == '*') {
p->flag == 0;
}
else p->y--;
}
}
int main() {
memset(map,0,sizeof(map));
for(int x=1;x<11;x++) {
for(int y=1;y<11;y++) {
cin>>map[x][y];
if(map[x][y]=='F') {
farm.x=x;
farm.y=y;
}
else if(map[x][y]=='C') {
cow.x=x;
cow.y=y;
}
}
}
for(int i=0;i<12;i+=11) {
for(int j=0;j<12;j++) map[i][j]='*';
}
for(int i=0;i<12;i+=11) {
for(int j=0;j<12;j++) map[j][i]='*';
}
cow.flag=0;
farm.flag=0;
int cnt=0;
man*pp=&farm;
man*qq=&cow;
while(cow.x!=farm.x||cow.y!=farm.y) {
cnt++;
move(pp);
move(qq);
if(cnt>500000) {
cnt=0;
break;
}
}
cout<<cnt;
return 0;
}