import Control.Monad
main = do
  [_,q] <- map read . words <$> getLine
  s <- getLine
  lrs <- replicateM q (map read . words <$> getLine) :: IO [[Int]]
  print $ ac s
  mapM_ (\[l,r] -> print . sum $ getLR l r (ac s)) lrs

ac :: String -> [Int] 
ac [] = []
ac [_] = []
ac (a:c:s)
  | [a,c] == "AC" = 1 : ac (c:s)
  | otherwise     = 0 : ac (c:s)
  
getLR :: Int -> Int -> [Int] -> [Int]
getLR l r acs = drop (l-1) $ take (r-1) acs