#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; string s; cin >> n >> s; int ans = 0; for (int j = 1; j + 1 < n; ++j) { if (s[j] != 'M') continue; for (int diff = 1; j - diff >= 0 && j + diff < n; ++diff) { int i = j - diff, k = j + diff; if (s[i] == 'U' && s[k] == 'G') ans++; } } cout << ans << endl; return 0; }