import qualified Data.Vector.Primitive as V
import qualified Data.Vector.Primitive.Mutable as V
import Control.Monad
import Control.Monad.State.Strict

readInts :: IO [Int]
readInts = map read . words <$> getLine

main = do

    n:q:_ <- readInts
    text <- V.fromList <$> getLine
    qs <- replicateM q readInts
    
    let table = flip evalState (0 :: Int) . V.generateM n $ \i ->
            if i /= 0 && text V.! (i-1) == 'A' && text V.! i == 'C'
            then modify' succ >> get
            else get

    forM_ qs $ \[s, e] -> print $ table V.! pred e - table V.! pred s