N =int(input()) S =[i for i in input()] dic = {"U":[],"M":[],"G":[]} for i,str in enumerate(S): dic[str].append(i) ans = 0 for j in dic["M"]: for i in dic["U"]: if i > j: break if 2*j - i in dic["G"]: ans += 1 print(i,j,2*j-i) print(ans)