let N = Int(readLine()!)! let S = String(readLine()!) let l = (N-3)/2 var c = 0 for i in 0...l{ //文字間隔 for j in 0...(N-1)-(i+1)*2{ //print(j,j+(i+1),j+(i+1)*2) var t = [S.index(S.startIndex, offsetBy: j)] t += [S.index(S.startIndex, offsetBy: j+(i+1))] t += [S.index(S.startIndex, offsetBy: j+(i+1)*2)] let T = t.map{String(S[$0])} if T.joined() == "UMG"{ c += 1 } } } print(c)