//2019.3.10
// support c++11
// g++ -O2 -std=gnu++17 -Wall -Wno-sign-compare eg.cpp -o eg
using namespace std;
#include <iostream>
#include <iomanip> //precision
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cstring> //memset, memory handle

#include <cmath>
#include <numeric>
#include <algorithm>
//python style
	//range->rep
	//print->D,put
	//len->size
	#define len size

//type abbr
	using ll = long long;
//int abbr
	using pii=pair<int,int>;
	using arr=vector<int>;
	#define val const int
//abbr
#define fi first
#define se second
#define pb push_back
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
//func abbr
	#define between(x,a,b) ((x-a)*(x-b)<=0) //between(2,10,0)
	#define maxn(x) const int maxn=x+10
	#define mineq(x,a) if(a<x) x=a
	#define maxeq(x,a) if(a>x) x=a
	#define Mem(x) memset(x,0,sizeof(x))
	#define put(x) cout<<x<<'\n'
	inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
	#define pow2(x) pow(2,x)
	#define lowbit(x) ((x)&(-x))
	//if not c++ 20
	#define ceil2(x) pow2(ceil(log2(x)))
	#define floor2(x) pow2(floor(log2(x)))
//pre set
	static int speedup = []() {ios::sync_with_stdio(0); cin.tie(NULL);return 0;}();/* io accelerater */

/* special */
#define GET_MACRO(_0,_1,_2,_3,_N,...) _N

/* control flow */
#define unless(x) if(!(x))
#define rep(...)  GET_MACRO(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
	#define rep4(i,a,b,c) for(int i=(a),_5=(b),_4=(c);_4*(i-_5)<0;i+=_4)
	#define rep3(i,a,b) for(int i=(a),_5=(b);i<_5;++i)
	#define rep2(i,a) rep3(i,0,a)
	#define rep1(a) rep2(_,a)
#define forEach(i, s) for(auto i=begin(s);i!=end(s);i++)
#define forEachN(i, s, n) for(auto i=begin(s),_6=next(i,n);i!=_6;i++)
#define forOnce if([]{static int i=-1;i++;return !i;}())
/* debug online judge */
#ifndef ONLINE_JUDGE
	int cout_width=7;
	//print c++ stl container and c array with constant array size;
		#define Da(...)  {cout<<#__VA_ARGS__<<'\n';GET_MACRO(__VA_ARGS__,X,Dvec2,Dvec1,Dset)(__VA_ARGS__);cout<<'\n';}
			#define D1(x) {cout<<" ";cout.width(cout_width);cout<<(x);}
			#define Dset(...) for(auto i : __VA_ARGS__ ) D1(i)
			#define Dvec1(x,fir) {forEachN(_7,x,fir) D1(*_7) cout<<'\n';}
			#define Dvec2(x,fir,sec) {for(auto _9=begin(x),_6=next(_9,sec),_7=next(_9,fir);_7!=_6;_7++) D1(*_7) cout<<'\n';}
		#define Da2(x,fir,sec) forEachN(_8,x,fir) Dvec1((*_8),sec)
	
	//print single element, arbitary args
		#define D(...) cout<<#__VA_ARGS__,Dout(__VA_ARGS__);
			void Dout(){cout<<'\n';}
			template<class T,class... U>
			void Dout(const T& h,const U&... t){
				D1(h);Dout(t...);
			}
	// additional print function 
		#define Ds(...)  {cout<<#__VA_ARGS__<<'\n';GET_MACRO(__VA_ARGS__,X,Darr2,Darr1,Dmap)(__VA_ARGS__);cout<<'\n';}
			//variable size c array
			#define Darr1(x,r)  {rep(i,r) D1(x[i]) cout<<"\n";}
			#define Darr2(x,r,c) rep(i,r) Darr1(x[i],c)
			// map
			template<class Map>
			void Dmap(const Map &mp){
				for(const auto &p:mp) {
					cout.width(cout_width);
					cout<<p.first<<" | ";
					cout.width(cout_width);
					cout<<p.second<<"\n";
				}
			}

#endif // ONLINE_JUDGE1
maxn(100000);
string S;
int N,Q,l,r;
int main(){
    cin>>N>>Q;
    cin>>S;
    
    arr ac;
    auto find=S.find("AC");
    while(find!=string::npos){
        ac.pb(find);    
        find=S.find("AC",find+1);
    }
    
    rep(_,Q){
        cin>>l>>r;
        l-=1;r-=1;
        int lac=lower_bound(all(ac),l)-begin(ac);
        int rac=upper_bound(all(ac),r-1)-begin(ac);
        put(rac-lac);
    }
}

Measured memory_bytes: 1228