import java.io.*;
public class Main {
static char[][] chars = new char[10][10];
static int rx = 0,ry = 0;
static int nx = 0,ny = 0;
static int lt = 0;
static int rlt = 0;
static int[] ints = {-1,0,0,1,1,0,0,-1};
static BufferedReader ins = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer in = new StreamTokenizer(ins);
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException{
char ct;
for(int i = 0;i<10;i++)
{
for(int i1 = 0;i1<10;i1++)
{
ct = (char)ins.read();
if(ct!='\n')
{
chars[i][i1] = ct;
if(ct == 'C')
{
nx = i;
ny = i1;
}
else if (ct == 'F')
{
rx = i;
ry = i1;
}
}
else
{
i1--;
}
}
}
int count = 0;
while(rx!=nx||ry!=ny)
{
nYD();
rYD();
count++;
if(count > 1000)
{
out.print(0);
out.close();
System.exit(0);
}
}
out.println(count);
out.close();
}
public static void nYD()
{
while(true)
{
if(nx+ints[lt]>=0&&nx+ints[lt]<10&&ny+ints[lt+1]>=0&&ny+ints[lt+1]<10&&chars[nx+ints[lt]][ny+ints[lt+1]]!='*')
{
nx += ints[lt];
ny += ints[lt+1];
break;
}
else
{
lt+=2;
lt%=8;
break;
}
}
}
public static void rYD()
{
while(true)
{
if(rx+ints[rlt]>=0&&rx+ints[rlt]<10&&ry+ints[rlt+1]>=0&&ry+ints[rlt+1]<10&&chars[rx+ints[rlt]][ry+ints[rlt+1]]!='*')
{
rx += ints[rlt];
ry += ints[rlt+1];
break;
}
else
{
rlt+=2;
rlt%=8;
break;
}
}
}
}