import Data.List
import qualified Data.Vector.Unboxed as V
import Control.Monad

f :: String -> [Int]
f [] = []
f [_] = []
f (c:d:s) = if (c,d) == ('A','C') then 1 : (f (d:s)) else 0 : (f (d:s))

solve :: Int -> V.Vector Int -> Int -> IO ()
solve _ _ 0 = return ()
solve n cnts q = do
  [l,r] <- map read.words <$> getLine
  print $ (cnts V.! (r-1)) - (cnts V.!(l-1))
  solve n cnts (q-1)

main :: IO ()
main = do
  [n,q] <- map read.words <$> getLine
  s <- getLine
  let cnts = V.fromList $ scanl (+) 0 $ f s
  solve n cnts q
