func main() var n: int :: cui@inputInt() var s: []char :: cui@input() var ans: int for i(0, n - 3) if(s[i] <> 'U') skip i end if for j(i + 1, n - 2) if(s[j] <> 'M') skip j end if if(2 * j - i < n & s[2 * j - i] = 'G') do ans :+ 1 end if end for end for do cui@print("\{ans}\n") end func