#include using namespace std; int main() { int n; string s; cin >> n >> s; int cnt = 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') { cnt++; } } } } cout << cnt << endl; return 0; }