#include<stdio.h>
#include<string.h>
#include<math.h>
struct ms
{
int x;
int y;
}k[4];
struct nn
{
int x;
int y;
int fx;
}n;
struct rr
{
int x;
int y;
int fx;
}r;
int main()
{
char map[12][12];
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
scanf("%c", &map[i][j]);
if (map[i][j] == 'F')
{
r.x = i;
r.y = j;
}
else if (map[i][j] == 'C')
{
n.x = i;
n.y = j;
}
}
getchar();
}
for (int i = 0; i < 12; i++)
{
map[0][i] = '*';
map[i][0] = '*';
map[11][i] = '*';
map[i][11] = '*';
}
k[0].x = -1;
k[0].y = 0;
k[1].x = 0;
k[1].y = 1;
k[2].x = 1;
k[2].y = 0;
k[3].x = 0;
k[3].y = -1;
n.fx = 0;
r.fx = 0;
int ans = 0;
while (1)
{
if (ans == 1000000000)break;
if (n.x == r.x && n.y == r.y)break;
if (map[n.x + k[n.fx].x][n.y + k[n.fx].y] == '*')
{
n.fx = (n.fx + 1) % 4;
}
else
{
n.x = n.x + k[n.fx].x;
n.y = n.y + k[n.fx].y;
}
if (map[r.x + k[r.fx].x][r.y + k[r.fx].y] == '*')
{
r.fx = (r.fx + 1) % 4;
}
else
{
r.x = r.x + k[r.fx].x;
r.y = r.y + k[r.fx].y;
}
ans++;
}
if (ans == 1000000000)printf("0");
else printf("%d", ans);
return 0;
}