#include<bits/stdc++.h>
using namespace std;
int zt[10000];
int mp[11][11];
int cx,cy,cf,fx,fy,ff,xx[4]={-1,0,1,0},yy[4]={0,1,0,-1},nt,stp;
int main()
{
for(int i=1;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
cin>>mp[i][j];
}
}
for(int i=1;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
if(mp[i][j]=='F')
{
fx=i;fy=j;
}
if(mp[i][j]=='C')
{
cx=i;cy=j;
}
}
while(1)
{
if(fx==cx&&fy==cy)
{
cout<<stp;
return 0;
}
nt=fx+fy*10+cx*100+cy*1000+ff*10000+cf*40000;
if(zt[nt])
{
cout<<stp;
return 0;
}
zt[nt]=1;
if(fx+xx[ff]<0||fx+xx[ff]>=10||fy+yy[ff]<0||fy+yy[ff]>=10||mp[fx+xx[ff]][fy+yy[ff]]=='*')
{
ff=(ff+1)%4;
}
else
{
fx=fx+xx[ff],fy=fy+yy[ff];
}
if(cx+xx[cf]<0||cx+xx[cf]>=10||cy+yy[cf]<0||cy+yy[cf]>=10||mp[cx+xx[cf]][cy+yy[cf]]=='*')
{
cf=(cf+1)%4;
}
else
{
cx=cx+xx[cf],cy=cy+yy[cf];
}
stp++;
}
}
}