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

s=eval(input())

a=[0]

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

  a.append(a[i-1]+s[i-1:i+1].count('AC'))

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=[0]

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

  a.append(a[i-1]+(s[i-1:i+1]=='AC'))

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 = [0]
for i in range(1, len(s)):
    a.append(a[i - 1] + s[i - 1 : i + 1].count("AC"))
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 = [0]
for i in range(1, len(s)):
    a.append(a[i - 1] + (s[i - 1 : i + 1] == "AC"))
for i in range(q):
    l, r = list(map(int, input().split()))
    print((a[r - 1] - a[l - 1]))

-    a.append(a[i - 1] + s[i - 1 : i + 1].count("AC")) +    a.append(a[i - 1] + (s[i - 1 : i + 1] == "AC"))