N,Q = (int(i) for i in input().split())

S = eval(input())

acl = [0] * N

cnt = 0



for j in range(1,N):

  if S[j-1] == 'A' and S[j] == 'C':

    cnt += 1

  acl[j] = cnt

      

for k in range(Q):

  x,y = (int(i)-1 for i in input().split())

  print((acl[y]-acl[x]))
N,Q = (int(i) for i in input().split())

S = eval(input())

acl = [0 for i in range(N)]

cnt = 0

for j in range(1,N):

  if S[j-1] == 'A' and S[j] == 'C':

    cnt += 1

  acl[j] = cnt

      

for k in range(Q):

  x,y = list(map(int, input().split()))

  print((acl[y-1]-acl[x-1]))
N, Q = (int(i) for i in input().split())
S = eval(input())
acl = [0] * N
cnt = 0
for j in range(1, N):
    if S[j - 1] == "A" and S[j] == "C":
        cnt += 1
    acl[j] = cnt
for k in range(Q):
    x, y = (int(i) - 1 for i in input().split())
    print((acl[y] - acl[x]))

N, Q = (int(i) for i in input().split())
S = eval(input())
acl = [0 for i in range(N)]
cnt = 0
for j in range(1, N):
    if S[j - 1] == "A" and S[j] == "C":
        cnt += 1
    acl[j] = cnt
for k in range(Q):
    x, y = list(map(int, input().split()))
    print((acl[y - 1] - acl[x - 1]))

-acl = [0] * N +acl = [0 for i in range(N)] -    x, y = (int(i) - 1 for i in input().split()) -    print((acl[y] - acl[x])) +    x, y = list(map(int, input().split())) +    print((acl[y - 1] - acl[x - 1]))