function Main(input) {
    // console.log(input);
    
    const N = input[0].split(" ")[0];
    const Q = input[0].split(" ")[1];
    const S = input[1];
    
    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(S[j] == "A" && S[j+1] == "C") {
                count++;
            }
        }
        console.log(count);
    }
}

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