#include<bits/stdc++.h>

using namespace std;
int main(){
	
	int n,k;
	cin>>n>>k;
string x;cin>>x;
	while(k--){																										
	int a,b; cin>>a>>b;a--;b--;

	int aux=a-b;
	int cont=0;
	while(b>a){
		if(x[a]=='A'){
			if(x[a+1]=='C'){
				cont++;
			}
		}
		a++;
	}
cout<<cont<<endl;
}
	return 0;
}
