"use strict";
    
const main = arg => {
    const N  = parseInt(arg.split("\n")[0].split(" ")[0]);
    const Q  = parseInt(arg.split("\n")[0].split(" ")[1]);
    const S  = arg.split("\n")[1].split("");
    const lr = arg.split("\n").slice(2, N + 1);
    let answer = 0;
    let dp = new Array(N).fill(0);
    
    
    for(let i=0; i<Q; i++) {
        let l = lr[i].split(" ")[0];
        let r = lr[i].split(" ")[1];

        let L;
        let R;
        
        if(dp[l-1] === 0) {
            L = S.slice(0, l).join("").split("AC").length - 1;
        } else {
            L = dp[l-1];
        }
        
        if(dp[r-1] === 0) {
            R = S.slice(0, r).join("").split("AC").length - 1;
        } else {
            R = dp[r-1];
        }
        
        dp[l-1] = S.slice(0, l).join("").split("AC").length - 1;
        dp[r-1] = S.slice(0, r).join("").split("AC").length - 1;

        console.log(R-L);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
