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