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

S = eval(input())

index = [0] *(N+1)

for i in range(N):

  index[i+1] = index[i] + (1 if S[i:i+2] =='AC' else 0)

for _ in range(Q):

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

  print((index[l-1] - index[ r -1]))
N,Q = list(map(int,input().split()))

S = eval(input())

index = [0] *(N+1)

for i in range(N):

  index[i+1] = index[i] + (1 if S[i:i+2]=='AC' else 0)

for _ in range(Q):

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

  print((index[r-1] - index[l-1]))
N, Q = list(map(int, input().split()))
S = eval(input())
index = [0] * (N + 1)
for i in range(N):
    index[i + 1] = index[i] + (1 if S[i : i + 2] == "AC" else 0)
for _ in range(Q):
    r, l = list(map(int, input().split()))
    print((index[l - 1] - index[r - 1]))

N, Q = list(map(int, input().split()))
S = eval(input())
index = [0] * (N + 1)
for i in range(N):
    index[i + 1] = index[i] + (1 if S[i : i + 2] == "AC" else 0)
for _ in range(Q):
    l, r = list(map(int, input().split()))
    print((index[r - 1] - index[l - 1]))

-    r, l = list(map(int, input().split())) -    print((index[l - 1] - index[r - 1])) +    l, r = list(map(int, input().split())) +    print((index[r - 1] - index[l - 1]))