import Control.Monad
main = do
  [_,q] <- map read . words <$> getLine
  s <- getLine
  lrs <- replicateM q (map read . words <$> getLine)
  mapM_ (\[l,r] -> print . countAC $ getLR l r s) lrs
  
getLR l r s = drop (l-1) (take r s)

countAC []          = 0
countAC ('A':'C':s) = 1 + countAC s
countAC (c:s)       = countAC s