function Main(input) {
    input = input.split("\n")
    var tmp = input[0].split(" ")
    var N = parseInt(tmp[0],10)
    var Q = parseInt(tmp[1],10)
    var S = input[1]
    input.shift()
    input.shift()
    var data = []
    for(var i=0; i<Q; i++){
        tmp = input[i].split(" ")
        var d = {
            l: parseInt(tmp[0],10),
            r: parseInt(tmp[1],10)
        }
        data.push(d)
    }
    for(var dd of data){
      res = S.slice(dd.l-1,dd.r)
      res = res.match(/AC/g,"-");
      if(!res)res = []
      console.log(res.length)
    }
 
    return 0
}