import Data.List
import Data.Array
getInts = do
    x <- getLine
    let y = map (read::String->Integer) (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' x q = do
    [a,b] <- getInts
    print $ (x ! (b-1)) - (x ! (a-1))
    if q > 1 then solve' x (q-1)
    else return ()

solve s n q = 
    solve' (listArray (0,n) (change s 0)) q

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