I=lambda:list(map(int,input().split()))

n,q=I()

s=eval(input())

a=[0]

for i in range(n):a+=[a[i]+(s[i-1:i+1]=='AC')]

for _ in[0]*q:l,r=I();print((a[r]-a[l]))
I=lambda:list(map(int,input().split()));n,q=I();s=eval(input());a=[0]

for i in range(n):a+=[a[i]+(s[i-1:i+1]=='AC')]

while q:l,r=I();print((a[r]-a[l]));q-=1
I = lambda: list(map(int, input().split()))
n, q = I()
s = eval(input())
a = [0]
for i in range(n):
    a += [a[i] + (s[i - 1 : i + 1] == "AC")]
for _ in [0] * q:
    l, r = I()
    print((a[r] - a[l]))

I = lambda: list(map(int, input().split()))
n, q = I()
s = eval(input())
a = [0]
for i in range(n):
    a += [a[i] + (s[i - 1 : i + 1] == "AC")]
while q:
    l, r = I()
    print((a[r] - a[l]))
    q -= 1

-for _ in [0] * q: +while q: +    q -= 1