'use strict'

function Main(input){
	let temp = input.trim().split('\n');
	const N = parseInt(temp[0].split(' ')[0]);
	const Q = parseInt(temp[0].split(' ')[1]);
	const S = temp[1];

	const answer = [];
	for(let i=0;i<Q;i++){
		const li = parseInt(temp[i+2].split(' ')[0]);
		const ri = parseInt(temp[i+2].split(' ')[1]);

		const myS = S.slice(li-1,ri);
		let count = 0;

		console.log(myS,li,ri);
		for(let j=0,l=myS.length-1;j<l;j++){
			if( myS[j]+myS[j+1] == 'AC' ){
				count++;
				j++;
			}
		}
		console.log(count);
	}

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
