#include <iostream>
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int vis[12][12][12][12][4][4];
int map[12][12];
int cnt;
struct pos
{
int x, y, dir;
} fa, co;
bool operator==(pos p1, pos p2)
{
if (p1.x == p2.x && p1.y == p2.y)
return true;
else
return false;
}
void operator++(pos &p)
{
int x = p.x + dx[p.dir];
int y = p.y + dy[p.dir];
if (map[x][y] != 0)
{
p.x = x;
p.y = y;
}
else
{
p.dir = (p.dir + 1) % 4;
}
}
int main()
{
for (int i = 1; i <= 10; ++i)
{
for (int j = 1; j <= 10; ++j)
{
char tmp;
scanf("%c", &tmp);
if (tmp != '*')
map[i][j] = 1;
if (tmp == 'F')
{
fa = {i, j, 0};
}
if (tmp == 'C')
{
co = {i, j, 0};
}
}
getchar();
}
while (1)
{
if (fa == co)
{
printf("%d", cnt);
break;
}
if (vis[fa.x][fa.y][co.x][co.y][fa.dir][co.dir]++ == 1)
{
printf("0");
return 0;
}
++cnt;
++fa;
++co;
}
return 0;
}