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

s=eval(input())

b=[0]*(n+1)

y=0

for x,i in enumerate(s):

    if i=="A" and x!=n-1 and s[x+1]=="C":

        y+=1

    b[x+1]=y

for i in range(q):

    a0,a1=list(map(int,input().split()))

    print((b[a1-1]-b[a0-1]))

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

a=eval(input())

ac=[0]*n

x=0

for i in range(n-1):

    if a[i]=='A' and a[i+1]=='C':

        x+=1

    ac[i+1]=x

ac[-1]=x

for i in range(k):

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

    print((ac[r-1]-ac[l-1]))
n, q = list(map(int, input().split()))
s = eval(input())
b = [0] * (n + 1)
y = 0
for x, i in enumerate(s):
    if i == "A" and x != n - 1 and s[x + 1] == "C":
        y += 1
    b[x + 1] = y
for i in range(q):
    a0, a1 = list(map(int, input().split()))
    print((b[a1 - 1] - b[a0 - 1]))

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

-n, q = list(map(int, input().split())) -s = eval(input()) -b = [0] * (n + 1) -y = 0 -for x, i in enumerate(s): -    if i == "A" and x != n - 1 and s[x + 1] == "C": -        y += 1 -    b[x + 1] = y -for i in range(q): -    a0, a1 = list(map(int, input().split())) -    print((b[a1 - 1] - b[a0 - 1])) +n, k = list(map(int, input().split())) +a = eval(input()) +ac = [0] * n +x = 0 +for i in range(n - 1): +    if a[i] == "A" and a[i + 1] == "C": +        x += 1 +    ac[i + 1] = x +ac[-1] = x +for i in range(k): +    l, r = list(map(int, input().split())) +    print((ac[r - 1] - ac[l - 1]))