#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'M') { for (int j = 1; j < n; j++) { if (i - j < 0 || i + j >= n) break; ans += s[i - j] == 'U' && s[i + j] == 'G'; } } } cout << ans << endl; return 0; }