import Control.Monad                                                                                                                                  
                                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [_,q] <- map read . words <$> getLine                                                                                                               
  s <- getLine                                                                                                                                        
  lrs <- replicateM q $ (\[x,y] -> (x,y)) . map read . words <$> getLine :: IO [(Int,Int)]                                                            
  let acs = neighbour s                                                                                                                               
  forM_ lrs $ \(l,r) -> do                                                                                                                            
    let partS = drop (l-1) . take (r-1) $ acs                                                                                                         
    print $ sum partS                                                                                                                                 
                                                                                                                                                      
neighbour :: String -> [Int]                                                                                                                          
neighbour [] = []                                                                                                                                     
neighbour [_] = []                                                                                                                                    
neighbour (x:y:xs)                                                                                                                                    
  | [x,y] == "AC" = 1 : neighbour (y:xs)                                                                                                              
  | otherwise     = 0 : neighbour (y:xs)