#include<bits/stdc++.h>
using namespace std;
char a[12][12];
int f[2]={0,0},c[2]={0,0},c1=0,f1=0,ans=0;
bool fl[200000];
bool pd(){
if(f[0]==c[0]&&f[1]==c[1]){
return 0;
}else{
return 1;
}
}
void zl(int x,int y,int h){
if(h==1){
if(f1==0){
if(a[x-1][y]=='*'){
f1=1;
}else{
f[0]--;
}
}
if(f1==1){
if(a[x][y+1]=='*'){
f1=2;
}else{
f[1]++;
}
}
if(f1==2){
if(a[x+1][y]=='*'){
f1=3;
}else{
f[0]++;
}
}
if(f1==3){
if(a[x][y-1]=='*'){
f1=0;
}else{
f[1]--;
}
}
}else{
if(c1==0){
if(a[x-1][y]=='*'){
c1=1;
}else{
c[0]--;
}
}
if(c1==1){
if(a[x][y+1]=='*'){
c1=2;
}else{
c[1]++;
}
}
if(c1==2){
if(a[x+1][y]=='*'){
c1=3;
}else{
c[0]++;
}
}
if(c1==3){
if(a[x][y-1]=='*'){
c1=0;
}else{
c[1]--;
}
}
}
}
int main(){
memset(a,'*',sizeof(a));
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin>>a[i][j];
if(a[i][j]=='F'){
f[0]=i;
f[1]=j;
}
if(a[i][j]=='C'){
c[0]=i;
c[1]=j;
}
}
}
while(pd()){
int k=f[0]+f[1]*10+c[0]*100+c[1]*1000+f1*10000+c1*40000;
if(fl[k]){
cout<<0;
return 0;
}
fl[k]=true;
zl(f[0],f[1],1);
zl(c[0],c[1],0);
ans++;
}
cout<<ans;
return 0;
}