#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, s, x, c;
	cin >> n >> m;
	if (n != 1){
		return 0;
	}
	else {
		char a[m];
		for (int i = 0; i < m; i++){
			cin >> a[i];
			if (a[i] == 'S'){
				s = i;
			}
		}
		c = 1;
		x = s - 1;
		while (x >= 0){
			if (a[x] == '.'){
				c++;
			}
			else if (a[x] == '*'){
				break;
			}
			else {
				c -= (s - x) / 2;
				break;
			}
			x--;
		}
		x = s + 1;
		while (x < m){
			if (a[x] == '.'){
				c++;
			}
			else if (a[x] == '*'){
				break;
			}
			else {
				c -= (x - s) / 2;
				break;
			}
			x++;
		}
		cout << c;
	}
}