import Control.Monad
import Data.Array
main = do
  [n,q] <- map read . words <$> getLine
  s <- getLine
  lrs <- replicateM q (map read . words <$> getLine) :: IO [[Int]]
  let arr = array (1,n) . zip [1..n] $ ac 0 s
  mapM_ (\[l,r] -> print $ getLR l r arr) lrs

ac :: Int -> String -> [Int]
ac acc [] = []
ac acc [_] =  [acc]
ac acc (a:c:s)
  | [a,c] == "AC" = acc : (acc+1) : ac (acc+1) (s)
  | otherwise     = acc : ac acc (c:s)
  
getLR :: Int -> Int -> Array Int Int -> Int
getLR l r arr = (arr ! r) - (arr ! l)