let () =
  Scanf.scanf "%d %d %s" @@ fun n q s ->
  let ss = Array.init (n+1) (fun i -> 
    if i > 1 && s.[i-2] = 'A' && s.[i-1] = 'C' then 1 else 0) in
  for i = 1 to n do ss.(i) <- ss.(i) + ss.(i-1); done;
  Array.init q (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y))
  |> Array.iter (fun (l,r) ->
      let v = ss.(r) - ss.(l-1) in
      let v = if l > 1 && s.[l-2] = 'A' && s.[l-1] = 'C' then v-1 else v in
      Printf.printf "%d\n" v)
