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

s=eval(input())

a=[]

for i in range(len(s)-1):

  a.append(s[i:i+2])

b=[0]

for i in a:

  b.append(b[-1])

  if i=='AC':

    b[-1]+=1



for i in range(q):

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

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

s=eval(input())

a=[0]*(n+1)

for i in range(n-1):

  if s[i:i+2]=='AC':

    a[i+1]=1

for i in range(n):

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

for i in range(q):

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

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

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

-a = [] -for i in range(len(s) - 1): -    a.append(s[i : i + 2]) -b = [0] -for i in a: -    b.append(b[-1]) -    if i == "AC": -        b[-1] += 1 +a = [0] * (n + 1) +for i in range(n - 1): +    if s[i : i + 2] == "AC": +        a[i + 1] = 1 +for i in range(n): +    a[i + 1] += a[i] -    print((b[r - 1] - b[l - 1])) +    print((a[r - 1] - a[l - 1]))