import Data.List
import Data.Array
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' x q = do
    [a,b] <- getInts
    print $ (x ! b) - (x ! a)
    if q > 1 then solve' x (q-1)
    else return ()
 
solve s n q = 
    solve' (listArray (0,n) ([0]++(change s 0))) q
 
main::IO()
main=do
    [n,q] <- getInts
    s <- getLine
    solve s n q