'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 ACpos = [];

	for(let i=0;i<N-1;i++){
		if( (S[i]+S[i+1]) == 'AC' ) ACpos.push(i);
	}

	for(let i=0;i<Q;i++){
		const li = parseInt(temp[i+2].split(' ')[0]) - 1;
		const ri = parseInt(temp[i+2].split(' ')[1]) - 1;
		
		let count=0;
		for(let j=0,l=ACpos.length;j<l;j++){
			if( li <= ACpos[j] ){
				if( ACpos[j] < ri ){
					count++;
				}else{
					break;
				}
			}
		}

		console.log(count);
	}

}

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