from collections import deque

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

s=eval(input())

AC=deque()

count=0

for i in range(n):

    if i!=0:

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

            count+=1

    AC.append(count)

for _ in range(q):

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

    print((AC[r-1]-AC[l-1]))
n,q=[int(i) for i in input().split()]

s=eval(input())

AC=[0]*n

cnt=0

for i in range(1,n):

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

        cnt+=1

    AC[i]=cnt

for i in range(q):

    l,r=[int(j) for j in input().split()]

    print((AC[r-1]-AC[l-1]))
from collections import deque

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

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

-from collections import deque - -n, q = list(map(int, input().split())) +n, q = [int(i) for i in input().split()] -AC = deque() -count = 0 -for i in range(n): -    if i != 0: -        if s[i - 1 : i + 1] == "AC": -            count += 1 -    AC.append(count) -for _ in range(q): -    l, r = list(map(int, input().split())) +AC = [0] * n +cnt = 0 +for i in range(1, n): +    if s[i - 1 : i + 1] == "AC": +        cnt += 1 +    AC[i] = cnt +for i in range(q): +    l, r = [int(j) for j in input().split()]