#include #include using namespace std; int main(){ int N; cin >> N; string S; cin >> S; int cnt = 0; int width = 1; while(width <= N/2){ for(int i = 0;i < N;i++){ if(i + 2 * width > N)break; else{ if(S[i] == 'U' && S[i+width] == 'M' && S[i+2*width] == 'G')cnt++; } } width++; } cout << cnt << endl; }