#include<iostream>
#include<string>
#include<cstring>
using namespace std;
char s[12][12];
int main()
{
int mx[] = { -1,0,1,0 }, my[] = { 0,1,0,-1},flag1=0,flag2=0,cnt=0,x1,y1,x2,y2;
memset(s, '0', sizeof(s));
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
cin >> s[i][j];
if (s[i][j] == '.') s[i][j] = '1';
else if (s[i][j] == '*') s[i][j] = '0';
else if (s[i][j] == 'F') {
x1 = i;
y1 = j;
s[i][j] = '1';
}
else if (s[i][j] == 'C') {
x2 = i;
y2 = j;
s[i][j] = '1';
}
}
}
while (x1 != x2||y1 != y2)
{
if (s[x1 + mx[flag1]][y1 + my[flag1]]=='1') {
x1 += mx[flag1];
y1 += my[flag1];
}
else if (s[x1 + mx[flag1]][y1 + my[flag1]] == '0')
{
flag1++;
}
if (s[x2 + mx[flag2]][y2 + my[flag2]]=='1') {
x2 += mx[flag2];
y2 += my[flag2];
}
else if (s[x2 + mx[flag2]][y2 + my[flag2]] == '0')
{
flag2++;
}
flag1%=4;
flag2 %= 4;
cnt++;
}
if (cnt >=160000) cout << 0;
else cout << cnt;
return 0;
}```