#include <stdio.h>
#include <string.h>
#include <math.h>
#define EPS 1000
int main(void)
{
char map[12][12]={{'0'}};
int i,j;
for( i = 0; i < 12; i++) {map[i][0] = '*';map[i][11] = '*';}
for( j = 1; j < 12; j++) {map[0][j] = '*';map[11][j] = '*';}
struct posion
{
int x,y;
};
struct posion F,C;
for( i = 1; i <= 10; i++) {
for( j = 1; j <= 10; j++) {
scanf("%c",&map[i][j]);
if(map[i][j] == 'F'){ F.x = i;F.y = j;}
if(map[i][j] == 'C'){C.x = i;C.y = j;}
}
getchar();
}
int ans=0;
int head_F = 0, head_C = 0;
while( ans<=EPS ) {
ans++;
if(head_F == 0) {
if( map[F.x-1][F.y] != '*' ) F.x--;
else head_F = (head_F + 1) % 4;
}
else if(head_F == 1) {
if( map[F.x][F.y+1] != '*' ) F.y++;
else head_F = (head_F + 1) % 4;
}
else if(head_F == 2) {
if( map[F.x+1][F.y] != '*' ) F.x++;
else head_F = (head_F + 1) % 4;
}
else if(head_F == 3) {
if( map[F.x][F.y-1] != '*' ) F.y--;
else head_F = (head_F + 1) % 4;
}
if(head_C == 0) {
if( map[C.x-1][C.y] != '*' ) C.x--;
else head_C = (head_C + 1) % 4;
}
else if(head_C == 1) {
if( map[C.x][C.y+1] != '*' ) C.y++;
else head_C = (head_C + 1) % 4;
}
else if(head_C == 2) {
if( map[C.x+1][C.y] != '*' ) C.x++;
else head_C = (head_C + 1) % 4;
}
else if(head_C == 3) {
if( map[C.x][C.y-1] != '*' ) C.y--;
else head_C = (head_C + 1) % 4;
}
if(F.x == C.x && F.y == C.y) break;
}
if(F.x!=C.x || F.y!=C.y) putchar('0');
else printf("%d",ans);
return 0;
}