N,Q=list(map(int,input().split()))

S=eval(input())

cs=[0]*N

cnt=0

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

  if S[i-1]=="A" and S[i]=="C":

    cnt+=1

  cs[i]=cnt

for i in range(Q):

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

  print((cs[r-1]-cs[l-1]))
import sys

readline = sys.stdin.readline



N,Q = list(map(int,readline().split()))

S = readline().rstrip()



cnt = [0] * (N + 1)

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

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

    cnt[i + 1] = 1

    

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

  cnt[i] = cnt[i - 1] + cnt[i]

  

for i in range(Q):

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

  print((cnt[r] - cnt[l]))

N, Q = list(map(int, input().split()))
S = eval(input())
cs = [0] * N
cnt = 0
for i in range(1, len(S)):
    if S[i - 1] == "A" and S[i] == "C":
        cnt += 1
    cs[i] = cnt
for i in range(Q):
    l, r = list(map(int, input().split()))
    print((cs[r - 1] - cs[l - 1]))

import sys

readline = sys.stdin.readline
N, Q = list(map(int, readline().split()))
S = readline().rstrip()
cnt = [0] * (N + 1)
for i in range(1, len(S)):
    if S[i - 1 : i + 1] == "AC":
        cnt[i + 1] = 1
for i in range(1, len(cnt)):
    cnt[i] = cnt[i - 1] + cnt[i]
for i in range(Q):
    l, r = list(map(int, readline().split()))
    print((cnt[r] - cnt[l]))

-N, Q = list(map(int, input().split())) -S = eval(input()) -cs = [0] * N -cnt = 0 +import sys + +readline = sys.stdin.readline +N, Q = list(map(int, readline().split())) +S = readline().rstrip() +cnt = [0] * (N + 1) -    if S[i - 1] == "A" and S[i] == "C": -        cnt += 1 -    cs[i] = cnt +    if S[i - 1 : i + 1] == "AC": +        cnt[i + 1] = 1 +for i in range(1, len(cnt)): +    cnt[i] = cnt[i - 1] + cnt[i] -    l, r = list(map(int, input().split())) -    print((cs[r - 1] - cs[l - 1])) +    l, r = list(map(int, readline().split())) +    print((cnt[r] - cnt[l]))