N = int(input()) S = input() if set(S)=={"U","M","G"}: print(0) else: candidates = ((i,j,k) for i in range(N - 2) for j in range(N - 1) for k in range(N) if i < j < k and j - i == k - j and S [i] == "U" and S[j] == "M" and S[k] == "G") print("PASS") count = len(list(candidates)) print(count)