import Data.List
getInts = do
    x <- getLine
    let y = map (read::String->Int) (words x) 
    return y

change [] n = []
change s n = 
    if isPrefixOf "AC" s then 
        [n] ++ change (tail s) (n + 1)
    else 
        [n] ++ change (tail s) n

solve s n q = do
    [a,b] <- getInts
    let x = change s 0
    print $ (x!!(b-1)) - (x!!(a-1))
    if q > 1 then solve s n (q-1)
    else return ()

main::IO()
main=do
    [n,q] <- getInts
    s <- getLine
    solve s n q
