#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 1e5 + 10;
char s[15][15];
int ci, cj, fi, fj, res;
int next[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int main()
{
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
s[i][j] = '*';
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
scanf("%c", &s[i][j]);
if (s[i][j] == 'C') ci = i, cj = j;
else if (s[i][j] == 'F') fi = i, fj = j;
}
getchar();
}
int cx,cy, fx, fy, dc = 0, df = 0;
cx = ci, cy = cj, fx = fi, fy = fj;
while (1)
{
res++;
int tc = dc%4, tf = df%4;
if (s[cx + next[tc][0]][cy + next[tc][1]] == '*') dc++;
else cx += next[tc][0], cy += next[tc][1];
if (s[fx + next[tf][0]][fy + next[tf][1]] == '*') df++;
else fx += next[tf][0], fy += next[tf][1];
if (cx == fx && cy == fy) break;
else if (res > 160000)
{
res = -1;
break;
}
}
if (res == -1) printf("0");
else printf("%d", res);
return 0;
}