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