using namespace std;
#define x first
#define y second
int main()
{
char s[11][11];
pair<int,int> a, b, c;
for(int i = 0; i < 10; i ++)
{
for(int j = 0; j < 10; j ++)
{
cin >> s[i][j];
if(s[i][j]=='B')a = {i, j};
if(s[i][j]=='L')b ={i ,j};
if(s[i][j]=='R')c ={i, j};
}
}
if(a.x == b.x &&a.x==c.x&&abs(c.y - a.y) + abs(b.y - c.y) == abs(a.y - b.y))cout << abs(a.x - b.x) + abs(a.y - b.y) + 1;
else if(a.y == b.y &&c.y == a.y&& abs(c.x - a.x) + abs(b.x -c.x)==abs(a.x - b.x))cout << abs(a.x - b.x) + abs(a.y - b.y) + 1;
else cout << abs(a.x - b.x) + abs(a.y - b .y) - 1;
}