import Data.List
import Control.Monad
import qualified Data.Vector as V
main = do
    [n, q] <- fmap read . words <$> getLine :: IO [Int]
    s <- getLine

    let ac = V.fromList . scanl (+) 0 $ (\x -> if x == "AC" then 1 else 0) . take 2 <$> tails s
    forM_ [1..q] . const $ do
        [l, r] <- fmap pred . fmap read . words <$> getLine
        print $ (ac V.! r) - (ac V.! l)
