N,Q=list(map(int,input().split()))

S=eval(input())

l=0

r=0



s=[]

s.append(0)



for i in range(1,N):

    if(S[i-1]=='A' and S[i]=='C'):



        s.append(s[i-1]+1)



    else:

        s.append(s[i-1])



for i in range(Q):



    l,r=list(map(int,input().split()))



    print((s[r-1]-s[l-1]))

N,Q=list(map(int,input().split()))

S=eval(input())

l=0

r=0

l=[0]*Q

r=[0]*Q

s=[]

s.append(0)



for i in range(1,N):

    if(S[i-1]=='A' and S[i]=='C'):



        s.append(s[i-1]+1)



    else:

        s.append(s[i-1])



for i in range(Q):



    l[i],r[i]=list(map(int,input().split()))

for i in range(Q):

    print((s[r[i]-1]-s[l[i]-1]))



N, Q = list(map(int, input().split()))
S = eval(input())
l = 0
r = 0
s = []
s.append(0)
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        s.append(s[i - 1] + 1)
    else:
        s.append(s[i - 1])
for i in range(Q):
    l, r = list(map(int, input().split()))
    print((s[r - 1] - s[l - 1]))

N, Q = list(map(int, input().split()))
S = eval(input())
l = 0
r = 0
l = [0] * Q
r = [0] * Q
s = []
s.append(0)
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        s.append(s[i - 1] + 1)
    else:
        s.append(s[i - 1])
for i in range(Q):
    l[i], r[i] = list(map(int, input().split()))
for i in range(Q):
    print((s[r[i] - 1] - s[l[i] - 1]))

+l = [0] * Q +r = [0] * Q -    l, r = list(map(int, input().split())) -    print((s[r - 1] - s[l - 1])) +    l[i], r[i] = list(map(int, input().split())) +for i in range(Q): +    print((s[r[i] - 1] - s[l[i] - 1]))