let n = stdin.ReadLine () |> int let s = stdin.ReadLine () [| for i in 0..(n-1)/2 -> [| for j in 0..n-3-2*i -> s.[j] = 'U' && s.[j+i+1] = 'M' && s.[j+2*i+2] = 'G' |] |] |> Array.concat |> Array.filter id |> Array.length |> printfn "%d"