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