{-# LANGUAGE OverloadedStrings #-} 
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.Text as T

getSub :: Int -> Int -> T.Text -> T.Text
getSub from to = T.take (to - from + 1) .  T.drop (from - 1)  

solve :: T.Text ->  (Int, Int) -> Int
solve t (s,e) = T.count "AC"  $ getSub s e t

main = do
    (len, lines) <- readTuple :: IO (Int, Int)
    s <- T.pack <$> getLine 
    replicateM lines (readTuple >>= print . solve s)


readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)