let readString() = stdin.ReadLine()
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()
let queries = [for _ in [1..q] -> readIntArray()]

let rec solve (str: string) = 
    if str.Length = 0 then 
        0
    else 
        let remain = str.Substring(1);
        if str.StartsWith("AC") then (solve remain) + 1 else solve remain

queries
|> List.map (fun x -> s.Substring(x.[0] - 1, x.[1] - x.[0] + 1))
|> List.map (fun x -> solve x)
|> fun x -> for i in x do printfn "%d" i