function Main(input){
  
  var str = input.trim().split("\n");
  var nq = str[0].split(" ");
  var n = nq[0];
  var q = nq[1];
  var s = str[1];
  var lr = str;
  lr.splice(0,2);
  
  //console.log("l:"+lr[0].split(" ")[0]);
  //console.log("l:"+lr[0].split(" ")[1]);  
  
  var s = s.replace(/AC/g,"aC");
  
//console.log("S:"+s);  
  
  for(i=0;i<q;i++){
      var kaisu = 0;
    var tmps = s.substring(lr[i].split(" ")[0]-1,lr[i].split(" ")[1]);
    var kaisu = str.split("a").length;
    console.log(kaisu);
    
  }//for end
  

  
    
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));