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

s=eval(input())



ac_count=[]

ac=0



for i in range(n-1):

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

        ac+=1

    ac_count.append(ac)

    

for i in range(q):

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

    if l==1:

        print((ac_count[r-2]))

    else:

        print((ac_count[r-2]-ac_count[l-2]))
import bisect

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

s=eval(input())

lr=[[int(i) for i in input().split()] for j in range(q)]



li=[]

for i in range(n-1):

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

        li+=[i]

ans=0

for l,r in lr:

    left=bisect.bisect_left(li,l-1)

    right=bisect.bisect_right(li,r-2)

    print((right-left))

    

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

import bisect

n, q = list(map(int, input().split()))
s = eval(input())
lr = [[int(i) for i in input().split()] for j in range(q)]
li = []
for i in range(n - 1):
    if s[i] + s[i + 1] == "AC":
        li += [i]
ans = 0
for l, r in lr:
    left = bisect.bisect_left(li, l - 1)
    right = bisect.bisect_right(li, r - 2)
    print((right - left))

+import bisect + -ac_count = [] -ac = 0 +lr = [[int(i) for i in input().split()] for j in range(q)] +li = [] -    if s[i : i + 2] == "AC": -        ac += 1 -    ac_count.append(ac) -for i in range(q): -    l, r = list(map(int, input().split())) -    if l == 1: -        print((ac_count[r - 2])) -    else: -        print((ac_count[r - 2] - ac_count[l - 2])) +    if s[i] + s[i + 1] == "AC": +        li += [i] +ans = 0 +for l, r in lr: +    left = bisect.bisect_left(li, l - 1) +    right = bisect.bisect_right(li, r - 2) +    print((right - left))