import strutils let read* = iterator: string = while true: (for s in stdin.readLine.split: yield s) template input*(T: static[typedesc]): untyped = when T is int: read().parseInt elif T is float: read().parseFloat elif T is string: read() elif T is char: read()[0] let N = input(int) let S = "#" & input(string) var res = 0 for i in 1 .. N: if S[i] == 'M': for j in 1 .. N: if 1 <= i - j and i + j <= N: if S[i - j] == 'U' and S[i + j] == 'G': inc res else: break echo res