#include<bits/stdc++.h>
using namespace std;
bool flag[15][15];
int fxf=0,fxc=0,tf,tc;
int nxf,nyf,nxc,nyc;
queue<pair<int,int> > cow;
queue<pair<int,int> > farmer;
int ok1(int n)
{
if(n==0)
return -1;
if(n==1)
return 0;
if(n==2)
return 1;
if(n==3)
return 0;
}
int ok2(int n)
{
if(n==0)
return 0;
if(n==1)
return 1;
if(n==2)
return 0;
if(n==3)
return -1;
}
void movecow()
{
if(cow.front().first==1||cow.front().first==10||cow.front().second==10)
{
fxc++,tc++;
return;
}
if(cow.front().second==1)
{
fxc=0,tc++;
return;
}
int nxc=cow.front().first+ok1(fxc);
int nyc=cow.front().second+ok2(fxc);
cow.push(make_pair(nxc,nyc));
tc++;
cow.pop();
}
void movefarmer()
{
if(farmer.front().first==1||farmer.front().first==10||farmer.front().second==10)
{
fxf++,tf++;
return;
}
if(farmer.front().second==1)
{
fxf=0,tf++;
return;
}
int nxf=farmer.front().first+ok1(fxf);
int nyf=farmer.front().second+ok2(fxf);
farmer.push(make_pair(nxf,nyf));
tf++;
farmer.pop();
}
void bfs()
{
while(!cow.empty()&&!farmer.empty())
{
if(nxc==nyc&&nxf==nyf)
{
cout<<min(tf,tc);
return;
}
movecow();
movefarmer();
}
cout<<0;
return;
}
int main()
{
for(int i=1;i<=10;i++)
for(int j=1;j<=10;j++)
{
char ch;
cin>>ch;
if(ch=='C')
cow.push(make_pair(i,j));
if(ch=='F')
farmer.push(make_pair(i,j));
if(ch=='.')
flag[i][j]=0;
if(ch=='*')
flag[i][j]=1;
}
bfs();
return 0;
}