import Control.Monad
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V

main = do
  [_,q] <- map read.words<$>getLine
  s <- getLine
  lrs <- replicateM q $ map read.words<$>getLine
  mapM_ print $ solve s lrs

solve :: String -> [[Int]] -> [Int]
solve s = go
  where
  go [] = []
  go ([l,r]:lrs) = memo!r - memo!l : go lrs
  memo = V.fromList $ go 0 s
    where
    go n [] = [n]
    go n ('A':'C':s) = n:n:go (n+1) s
    go n (c:s) = n:go n s