"use strict";
function Main(input) {
    let lines = input.split("\n");
    const nums = lines.shift().split(/\s/).map((v) => v - 0);
    const N = nums[0], Q = nums[1];
    let S = lines.shift().split(/\s/)[0];
    let T = new Array(N).fill(0);
    for (let m = 0; m < S.length-1; m++) {
        T[m + 1] = T[m] + ((S.substr(m, 2) == 'AC') ? 1 : 0);
    }
    for (let n = 0; n < Q; n++) {
        let v = lines.shift().split(/\s/).map((v) => v - 0 - 1);
        console.log(T[v[1]] - T[v[0]]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
