module Main where

import Control.Monad
import Data.List
import Data.List.Split
import Data.Array.IO
import qualified Data.Vector as V

main :: IO ()
main = do
  [n,q] <- map read . words <$> getLine
  s <- getLine
  lrs <- replicateM q $ map read . words <$> getLine :: IO [[Int]]

  let as = map (`solve` s) lrs

  mapM_ print as

solve (l:r:_) s = count 0 (getS l r (V.fromList s))
  where
    count c [] = c
    count c [_] = c
    count c (s1:s2:ss) | s1 == 'A' && s2 == 'C' = count (c + 1) ss
                       | otherwise = count c (s2:ss)

getS l r s = f l r s 0
  where
    f l r s i | i < l - 1 = f l r s $ i + 1
              | i < r  = (s V.! i) : f l r s (i + 1)
              | otherwise = ""