function main (sdi) {
  var v = sdi.split("\n");
  var N = v[0].split(" ");[0];
  var Q = v[0].split(" ");[1];
  var S = v[1].trim();
  for(var i=2; i<v.length; i++){
    var s = parseInt(v[i].split(" ")[0]);
    var e = parseInt(v[i].split(" ")[1]);
    var news = S.substr(s-1, e-s+1);
    var count = 0;
    var res = news.match(/AC/g);
    count = res ? res.length : 0;
    console.log(count);
  }
}

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