function binary_sort(array,value){ 
  const a = array;
  const search_value = value;
  const a_len = a.length -1;
  var left = 0; // index
  var right = a.length - 1; // index
  var count = 0;
  var index = 0;
  if (search_value <= a[0]) {
    return 0;
  } else if (search_value > a[a_len]) {
    return a_len+1;
  } else {
    while (left <= right) {
      count++;
      middle = Math.floor( (left + right) / 2 );
      if (search_value == a[middle]) {
        //console.log("middle : " + middle); 
        return middle;
      } else if (search_value < a[middle]) {
        right = middle;
      } else {
        left = middle;
      }
      //console.log("left : " + left + " / right : " + right);
      if ( (right - left) <= 1) {
        //console.log("-----------");
        index = right;
        //console.log("index(right) : " + index);
        //console.log("count : " + count);
        return index;
      }
    }
  }

}  
function Main(input){
  input_text = input.split('\n');
  N_Q = input_text[0].split(' ');
  N = N_Q[0];
  Q = N_Q[1];
  S = input_text[1];
  count = 0;
  AC_Array = [];
  for(k=0;k<N-1;k++){
    if(S[k] === 'A' && S[k+1] === 'C'){
      AC_Array.push(k);
    }
  }
  AC_Array_len = AC_Array.length;
  //console.log(AC_Array);
  for(i=0;i<Q;i++){
    l_r = input_text[i+2].split(' ');
    l = l_r[0]-1;	//index
    r = l_r[1]-1;	//index
    //console.log("=====[ l : " + l + " / r : " + r + "]");
    var count_low = AC_Array_len - binary_sort(AC_Array,l);
    //console.log("count_low : " + count_low);
    var count_high = AC_Array_len - binary_sort(AC_Array,r);
    //console.log("count_high : " + count_high);
    console.log(count_low - count_high);
    count=0;
  }
}
 
Main(require("fs").readFileSync("/dev/stdin","utf-8"));