import java.io.*;
import java.util.*;
import java.math.*;

public class q3 
{
	public static char map[][];
	public static boolean past[][];
	public static int total;
	
	public static void main(String[] args)throws IOException
	{
		BufferedReader bf = new BufferedReader(new FileReader("DATA3.txt"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("OUT3.txt")));
		
		for (int a = 0; a < 5; a++)
		{
			map = new char[10][10];
			past = new boolean [10][10];
			total = 0;
			int x = 0, y = 0;
			
			for (int i = 0; i < 10; i++)
			{
				String s = bf.readLine();
				for (int j = 0; j < 10; j++)
				{
					map[i][j] = s.charAt(j);
					if (map[i][j] == 'A')
					{
						x = i;
						y = j;
					}
				}
			}
			
			count (x, y);
			out.println(total);
			bf.readLine();
		}
		
		out.close();
	}
	
	public static void count(int x, int y)
	{
		if (x > 9 || x < 0 || y > 9 || y < 0)
			return;
		if (past[x][y])
			return;
		
		if (map[x][y] == '#' || map[x][y] == 'A')
			total++;
		else 
			return;
		
		past[x][y] = true;
		
		count (x + 1, y);
		count (x - 1, y);
		count (x, y + 1);
		count (x, y - 1);
		
		
		return;
	}
	
}
