using System;
class HelloWorld 
{
    static void Main() 
    {
        int n, m;
        var ulaz = Console.ReadLine().Split();
        n = int.Parse(ulaz[0]);
        m = int.Parse(ulaz[1]);
        int brojac = 0;
        int provera = n*m;
        
        
        char[,] matrica = new char[n, m];  

        for (int i = 0; i < n; i++) 
        {
            string znakovi = Console.ReadLine();  
            
            for (int j = 0; j < m; j++) 
            {
                matrica[i, j] = znakovi[j];
                if(matrica[i,j]=="."||matrica[i,j]=="S")
                {
                    brojac++;
                }
            }
        }

        if(brojac == provera)
        {
            Console.WriteLine(brojac);
            return;
        }
        
    }
}