#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 = 0; j < n - 1; j++) { for (int k = 0; k < n; k++) { if (j - i == k - j>0&&s[i] == 'U'&&s[j] == 'M'&&s[k] == 'G') { l += 1; } } } } cout << l << endl; return 0; }