n,q=list(map(int,input().split()))

s=eval(input())

a=[0]*n

for i in range(1,n):

  if s[i-1]=="A" and s[i]=="C":a[i]+=1

  a[i]+=a[i-1]

for i in range(q):

  aa,b=list(map(int,input().split()))

  print((a[b-1]-a[aa-1]))
n,q=list(map(int,input().split()))

s=eval(input())

lr=[list(map(int,input().split()))for _ in range(q)]

b=[0,0]

for i in range(1,n):

  b.append(b[-1])

  if s[i-1:i+1]=="AC":b[-1]+=1

for l,r in lr:print((b[r]-b[l]))
n, q = list(map(int, input().split()))
s = eval(input())
a = [0] * n
for i in range(1, n):
    if s[i - 1] == "A" and s[i] == "C":
        a[i] += 1
    a[i] += a[i - 1]
for i in range(q):
    aa, b = list(map(int, input().split()))
    print((a[b - 1] - a[aa - 1]))

n, q = list(map(int, input().split()))
s = eval(input())
lr = [list(map(int, input().split())) for _ in range(q)]
b = [0, 0]
for i in range(1, n):
    b.append(b[-1])
    if s[i - 1 : i + 1] == "AC":
        b[-1] += 1
for l, r in lr:
    print((b[r] - b[l]))

-a = [0] * n +lr = [list(map(int, input().split())) for _ in range(q)] +b = [0, 0] -    if s[i - 1] == "A" and s[i] == "C": -        a[i] += 1 -    a[i] += a[i - 1] -for i in range(q): -    aa, b = list(map(int, input().split())) -    print((a[b - 1] - a[aa - 1])) +    b.append(b[-1]) +    if s[i - 1 : i + 1] == "AC": +        b[-1] += 1 +for l, r in lr: +    print((b[r] - b[l]))