module ABC122.C

open System

let readPair () =
    Console.ReadLine().Split " "
    |> Array.map int
    |> fun array -> array.[0], array.[1]

let rec countAC cnt prev slst =
    match prev, slst with
    | None, [] -> cnt
    | None, head :: tail -> countAC cnt (Some head) tail
    | Some p, [] -> cnt
    | Some 'A', 'C' :: tail -> countAC (cnt + 1) (Some 'C') tail
    | Some p, x :: tail -> countAC cnt (Some x) tail

[<EntryPoint>]
let main argv =
    let (n, q) = readPair()
    let s = Console.ReadLine()
    for i in 1..q do
        let (l, r) = readPair()
        s.[(l-1)..(r-1)]
        |> Seq.toList
        |> countAC 0 None
        |> printfn "%d"
    0
