import java.io.*;
import java.awt.*;

public class problem4
{
    public static void main (String[] args) throws IOException
    {
	BufferedReader in = new BufferedReader (new FileReader ("DATA4.txt"));
	PrintWriter out = new PrintWriter (new FileWriter ("OUT4.txt"));
	for (int i = 0 ; i < 5 ; i++)
	{
	    char[] [] a = new char [10] [10];
	    boolean[] [] marked = new boolean [10] [10];

	    for (int x = 0 ; x < 10 ; x++)
		for (int y = 0 ; y < 10 ; y++)
		    marked [x] [y] = false;

	    for (int j = 0 ; j < 10 ; j++)
	    {
		String str = in.readLine ();
		a [j] = str.toCharArray ();
	    }
	    int time = 0;
	    int tCount = 0;
	    int preTCount = 0;
	    while (1 != 0)
	    {
		time++;

		for (int x = 0 ; x < 10 ; x++)
		    for (int y = 0 ; y < 10 ; y++)
			if (a [x] [y] == 'T')
			    tCount++;
			else if (a [x] [y] == 'F')
			{
			    if (x != 0)
				if (a [x - 1] [y] == 'T')
				    marked [x - 1] [y] = true;
			    if (x != 9)
				if (a [x + 1] [y] == 'T')
				    marked [x + 1] [y] = true;
			    if (y != 0)
				if (a [x] [y - 1] == 'T')
				    marked [x] [y - 1] = true;
			    if (y != 9)
				if (a [x] [y + 1] == 'T')
				    marked [x] [y + 1] = true;
			}
			else
			    ;
		System.out.println (tCount);
		if (tCount == 0)
		{
		    out.println (time - 1);
		    break;
		}
		if (tCount == preTCount)
		{
		    out.println (-1);
		    break;
		}
		for (int x = 0 ; x < 10 ; x++)
		{
		    for (int y = 0 ; y < 10 ; y++)
		    {
			if (marked [x] [y])
			{
			    a [x] [y] = 'F';
			    marked [x] [y] = false;
			}
		    }
		}
		preTCount = tCount;
		tCount = 0;

	    }
	    String temp;
	    if (i != 5)
		temp = in.readLine ();
	}
	out.close ();
    }
}



