#include #include using namespace std; int n; string s; int main(void) { cin >> n; cin >> s; int ans = 0; for(int i = 0; i < n; i++){ if(s[i] != 'M') continue; for(int j = 0; j < n; j++){ if(i-j < 0 || i+j >= n) continue; if(s[i-j] == 'U' && s[i+j] == 'G') ans++; } } cout << ans << endl; return 0; }