#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=;
char ch[SZ][SZ];
bool vst[SZ][SZ][][SZ][SZ][];
int dx[]={-,,,},dy[]={,,,-};
int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
for(int i=;i<=;++i)cin>>ch[i]+;
int fx,fy,cx,cy;
for(int i=;i<=;++i)
{
for(int j=;j<=;++j)
{
if(ch[i][j]=='F')fx=i,fy=j;
if(ch[i][j]=='C')cx=i,cy=j;
}
}
vst[fx][fy][][cx][cy][]=;
int dc=,df=;
int time=;
//cout<<fx<<" "<<fy<<" "<<cx<<" "<<cy<<endl;
for(;;)
{
int nfx=fx+dx[df],nfy=fy+dy[df];
int ncx=cx+dx[dc],ncy=cy+dy[dc];
if(nfx>=&&nfx<=&&nfy>=&&nfy<=&&ch[nfx][nfy]!='*')
{
fx=nfx,fy=nfy;
}
else df=(df+)%;
if(ncx>=&&ncx<=&&ncy>=&&ncy<=&&ch[ncx][ncy]!='*')
{
cx=ncx,cy=ncy;
}
else dc=(dc+)%;
++time;
if(fx==cx&&fy==cy)
{
cout<<time<<endl;
break;
}
if(vst[fx][fy][df][cx][cy][dc]==)
{//cout<<fx<<" "<<fy<<" "<<cx<<" "<<cy<<endl;
cout<<<<endl;
break;
}
vst[fx][fy][df][cx][cy][dc]=;
}
}
return ;
}