using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            char[] a = new char[1100];
            string[] s=Console.ReadLine().Split();
            n = int.Parse(s[0]);
            m = int.Parse(s[1]);
            if (n == 1)
            {
                int[] poljes = new int[1100];
                int[] poljev = new int[1100];
                for (int i = 0; i < m; i++)
                {
                    a[i] = (char)Console.Read();
                    poljes[i] = m + 10;
                    poljev[i] = m + 10;
                }
                for (int i = 0; i < m; i++)
                {
                    for (int j = i; j < m; j++)
                    {
                        if(a[j]=='S') poljes[i]=j-i;
                        if (a[j] == 'X') poljev[i] = j - i;
                        if (a[j] == '*') j = m;
                    }
                    for (int j = i; j >= 0; j--)
                    {
                        if (a[j] == 'S') poljes[i] = i - j;
                        if (a[j] == 'X') poljev[i] = i - j;
                        if (a[j] == '*') j = -1;
                    }
                
                }
                int brojac=0;
                for (int i = 0; i < m; i++)
                {
                    if (poljes[i] < poljev[i]) brojac++;
                }
                Console.WriteLine(brojac);
            }
        }
    }
}