'use strict';

function Main(input) {
  const N = input.split("\n")[0].split(" ")[0]
  const Q = input.split("\n")[0].split(" ")[1]
  const S = input.split("\n")[1]
  const Qlist = input.split("\n").slice(2)
    .map(x => x.split(" "))
  for (let Question of Qlist) {
    let piece = S.slice(Question[0]-1, Question[1])
    const answer = piece.split("AC").length-1
    console.log(answer)
  }
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
