/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n, m;
    cin >> n >> m;
    if(n == 1){
        int k;
        char mapa[m];
        for(int i = 0; i < m ;i++)
        {
            cin >> mapa[i];
            if(mapa[i] == 'S'){
                k = i;
            }
            
        }
        int levo = -1, desno = -1;
        for(int i = k+1; i < m;i++){
            if(mapa[i] != '.' && desno == -1){
                desno = i;
                //cout << desno << endl;
                break;
                
            }
        }
        for(int i = k-1; i >= 0;i--){
            if(mapa[i] != '.' && levo == -1){
                levo = i;
                //cout << levo << endl;
                break;
        }
        }
        //cout << levo << " " << levozid << " " << desno << " " << desnozid << " " << k;
        int sol = 0;
        if(levo == -1){
            sol += k;
        }
        else if(mapa[levo] == '*'){
        
            sol += k-levo-1;
            //cout << "sol += " << k-levo-1;
            
        }
        else{
            int g = k-levo-1;
            g -= g%2;
            g/=2;
            sol+= g;
            //cout << " sol+=" << g;
        }
         if(desno == -1){
            sol += m-k-1;
            //cout << "sol+= " << m-k-1;
        }
        else if(mapa[desno] == '*'){
        
            sol += desno-k-1;
             
        }
        else{
            int g = desno-k-1;
            g -= g%2;
            g/=2;
            sol+= g;
        }
        sol++;
        cout << sol;
}
    return 0;
}