
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readUint() = readString() |> uint64
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let n, q = readIntArray() |> fun x -> (x.[0], x.[1])
let s = readString().ToCharArray()
let queries = [for _ in [1..q] -> readIntArray()]
let ary : int array = Array.zeroCreate n
for i in [0..n-2] do 
    Array.set ary (i+1) (if s.[i] = 'A' && s.[i+1] = 'C' then 1 else 0)
for i in [1..n-1] do 
    Array.set ary i (ary.[i-1] + ary.[i])

queries
|> List.iter (fun x -> printfn "%d" (ary.[x.[1]-1] -  ary.[x.[0]-1]))