from itertools import accumulate

from operator import add



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

S = eval(input())

idx_list = [1 if S[i:i + 2] == 'AC' else 0 for i in range(len(S) - 1)]

idx_list_cumsum = [0] + list(accumulate(idx_list, add))



for _ in range(Q):

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

  print((idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1]))

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

S = eval(input())

X = [list(map(int, input().split())) for _ in range(Q)]



cnt = [0] * (N + 1)

for i in range(N - 1):

    cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]



for l, r in X:

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

from itertools import accumulate
from operator import add

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

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

-from itertools import accumulate -from operator import add - -idx_list = [1 if S[i : i + 2] == "AC" else 0 for i in range(len(S) - 1)] -idx_list_cumsum = [0] + list(accumulate(idx_list, add)) -for _ in range(Q): -    l, r = list(map(int, input().split())) -    print((idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1])) +X = [list(map(int, input().split())) for _ in range(Q)] +cnt = [0] * (N + 1) +for i in range(N - 1): +    cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i] +for l, r in X: +    print((cnt[r - 1] - cnt[l - 1]))