/*
ID: niepeng1
LANG: C++
TASK: ttwo
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
using namespace std;
#define MAX2 12
char map[MAX2][MAX2];
//bool cond[MAX2][MAX2][MAX2][MAX2];
FILE *in, *out;
int farmer[3],cow[3];
//0 1 2 3
//h r d l
void Process(int &i,int &j,int &dir)
{
if(dir==0)
{
if(map[i-1][j] != '*')
{
map[i][j] = '.';
// cond[cow[0]][cow[1]][farmer[0]][farmer[1]] = true;
i--;
}
else
dir=(dir+1)%4;
return;
}
if(dir==1)
{
if(map[i][j+1] != '*')
{
map[i][j]='.';
// cond[cow[0]][cow[1]][farmer[0]][farmer[1]] = true;
j++;
}
else
{
dir=(dir+1)%4;
}
return;
}
if(dir==2)
{
if(map[i+1][j] != '*')
{
map[i][j]='.';
// cond[cow[0]][cow[1]][farmer[0]][farmer[1]] = true;
i++;
}
else
dir=(dir+1)%4;
return;
}
if(dir==3)
{
if(map[i][j-1] != '*')
{
map[i][j]='.';
// cond[cow[0]][cow[1]][farmer[0]][farmer[1]] = true;
j--;
}
else
dir=(dir+1)%4;
return;
}
}
int seek()
{
int count=0,i,j;
for(i=0;i <10000; i++)
for(j=0;j< 1000; j++)
{
count++;
Process(farmer[0],farmer[1],farmer[2]);
Process(cow[0],cow[1],cow[2]);
if(farmer[0] == cow[0] && farmer[1] == cow[1])
return count;
/* if(cond[cow[0]][cow[1]][farmer[0]][farmer[1]] == true)
{
cout<<count<<endl;
cout<<cow[0]<<" cow "<<cow[1]<<endl;
cout<<farmer[0]<<" farmer "<<farmer[1]<<endl;
}*/
}
return -1;
}
int main(void)
{
int i,j;
//bool *p;
char c;
in = fopen("ttwo.in", "r");
out = fopen("ttwo.out", "w");
//=cond[0][0][0];
/* for(i=0;i<MAX2*MAX2*MAX2*MAX2;i++)
{
*p=false;
p++;
}*/
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
fscanf(in,"%c",&map[i][j]);
if(map[i][j] == 'F')
{
farmer[0]=i;
farmer[1]=j;
farmer[2]=0;
}
if(map[i][j] == 'C')
{
cow[0]=i;
cow[1]=j;
cow[2]=0;
}
}
fscanf(in,"%c",&c);
}
for(j=0;j<MAX2;j++)
{
map[j][11]='*';map[j][0]='*';
map[0][j]='*';map[11][j]='*';
}
// cond[cow[0]][cow[1]][farmer[0]][farmer[1]]=true;
int tem = seek();
if(tem == -1)
fprintf(out,"0/n");//cout<<0<<endl;
else
fprintf(out,"%d/n",tem);//cout<<tem<<endl;
fclose(in);fclose(out);
return 0;
}