import java.util.*;
import java.io.*;

public class Q3
{
    public static void main(String[] args) throws IOException
    {
        Scanner in = new Scanner(new File("DATA3.txt"));
        PrintWriter out = new PrintWriter(new FileWriter("OUT3.txt"));
        String s;
        char[][] c;
        char[][] f;
        int x, y;
        int count;
        for (int i = 0; i < 5; i++)
        {
            c = new char[10][];
            x = 0;
            y = 0;
            for (int j = 0; j < 10; j++)
            {
                s = in.nextLine();
                if (s.indexOf('A') != -1) {
                    x = j;
                    y = s.indexOf('A');
                }
                c[j] = s.toCharArray();
            }
            try {
                in.nextLine();
            }
            catch(Exception e){}
            f = fill(c, x, y);
            count = 0;
            for (int j = 0; j < 10; j++)
            {
                for (int k = 0; k < 10; k++)
                {
                    if (f[j][k] == '#') {
                        count++;
                    }
                }
            }
            out.println(count);
        }
        in.close();
        out.close();
    }
    
    public static char[][] fill(char[][] in, int x, int y)
    {
        LinkedList<Integer[]> l = new LinkedList<Integer[]>();
        l.add(new Integer[]{x, y});
        in[x][y] = '#';
        Integer[] current;
        char[][] out = new char[10][10];
        while (!l.isEmpty())
        {
            current = l.removeFirst();
            try {
                if (in[current[0]][current[1]] == '#' && out[current[0]][current[1]] != '#')
                {
                    out[current[0]][current[1]] = '#';
                    l.add( new Integer[]{current[0]-1, current[1]});
                    l.add( new Integer[]{current[0]+1, current[1]});
                    l.add( new Integer[]{current[0], current[1]-1});
                    l.add( new Integer[]{current[0], current[1]+1});
                }
            }
            catch(Exception e){}
        }
        return out;
    }    
}
