function Main(input) {
    // console.log(input);
    
    const N = parseInt(input[0].split(" ")[0]);
    const Q = parseInt(input[0].split(" ")[1]);
    const S = input[1];
    
    var ctArr = [];

    for(var i = 0; i < N-1; i++) {
        if(S[i] == "A" && S[i+1] == "C") {
            ctArr.push(true);
        } else {
            ctArr.push(false);
        }
    }

    for(var i = 2; i < input.length; i++) {
        var l = input[i].split(" ")[0];
        var r = input[i].split(" ")[1];
        var count = 0;
        for(var j = l-1; j < r-1; j++) {
            if(ctArr[j]) {
                count++;
            }
        }
        console.log(count);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));
