#include #include #include #include #include #include #include #include #include using std::cerr; using std::cin; using std::cout; using std::endl; void OutputError(std::string s) { cerr << "\033[93m" << s << "\033[m" << endl; return; } int main(void) { cout << std::fixed << std::setprecision(10); cin.tie(0); std::ios::sync_with_stdio(false); int n; std::string s; cin >> n >> s; int result = 0; for (int center = 1; center < n - 1; center++) { if (s[center] == 'M') { int width = 1; while (center - width >= 0 && center + width < n) { int left = center - width, right = center + width; if (s[left] == 'U' && s[right] == 'G') { result++; } width++; } } } cout << result << endl; return 0; }