function Main(input){
    const arr = input.split('\n');
    const NQ = arr[0].split(' ').map(Number);
    const S = arr[1];
    const lq = [];
    let answer = 0;
    for(let i=2; i<arr.length; i++){
        lq.push(arr[i]);
    }
    for(let i=0; i<lq.length; i++){
        answer = 0;
        const left = lq[i].split(' ')[0];
        const right = lq[i].split(' ')[1];
        const string = S.slice(left-1, right);
        let j=0;
        while(true){
            const index = string.indexOf('AC', j);
            if(index>=0){ 
                answer++;
                j = index+1;
            } else {
                break;
            }
        }
        console.log(answer);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
