#include<bits/stdc++.h>
using namespace std;
char chy[15][15];
int n[3],f[3];
int ans,tsz;
bool can[160005];
void move(int x,int y,int d,int who)
{
if(d==0)
{
if(chy[x-1][y]=='*') if(who==0) n[3]=1;else f[3]=1;
else if(who==0) n[1]--;else f[1]--;
}
if(d==1)
{
if(chy[x][y+1]=='*') if(who==0) n[3]=2;else f[3]=2;
else if(who==0) n[2]++;else f[2]++;
}
if(d==2)
{
if(chy[x+1][y]=='*') if(who==0) n[3]=3;else f[3]=3;
else if(who==0) n[1]++;else f[1]++;
}
if(d==3)
{
if(chy[x][y-1]=='*') if(who==0) n[3]=0;else f[3]=0;
else if(who==0) n[2]--;else f[2]--;
}
}
bool judge()
{
if(n[1]==f[1]&&n[2]==f[2]) return false;
else return true;
}
int main()
{
for(int i=1;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
scanf("%c",&chy[i][j]);
if(chy[i][j]=='C') n[1]=i,n[2]=j;
if(chy[i][j]=='F') f[1]=i,f[2]=j;
}
}
for(int i=0;i<=11;i++) chy[0][i]='*',chy[11][i]='*',chy[i][0]='*',chy[i][11]='*';
while(judge())
{
tsz=f[1]+f[2]*10+n[1]*100+n[2]*1000+f[3]*10000+n[3]*40000;
if(can[tsz])
{
printf("0");
return 0;
}
can[tsz]=true;
move(n[1],n[2],n[3],0);
move(f[1],f[2],f[3],1);
ans++;
}
printf("%d",ans);
return 0;
}