const main = (input) => {
  const inputs = input.trim().split("\n");
  const N = Number(inputs[0].split(" ")[0]);
  const Q = Number(inputs[0].split(" ")[1]);
  const S = inputs[1];

  for(var i=2;i<inputs.length;i++){
    var l = Number(inputs[i].split(" ")[0]);
    var r = Number(inputs[i].split(" ")[1]);
    var trg = S.substring(l-1,r);
    var ans = trg.match(/AC/g);
    if(ans){
      console.log(trg.match(/AC/g).length);
    }else{
      console.log(0);
    }
  }

}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
