import numpy as np



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

S = np.array(list('_' + eval(input())), dtype='U')



A = (S == 'A')

C = (S == 'C')

AC = A[:-1] & C[1:]

AC_cum = AC.cumsum()



for _ in range(Q):

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

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

S = eval(input())

B = [0] * N

for i in range(N-1):

    if S[i] == 'A' and S[i+1] == 'C':

        B[i] = 1

for i in range(1, N-1):

    B[i] += B[i-1]

for i in range(Q):

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

    print((B[r-2] - B[l-2]))
import numpy as np

N, Q = list(map(int, input().split()))
S = np.array(list("_" + eval(input())), dtype="U")
A = S == "A"
C = S == "C"
AC = A[:-1] & C[1:]
AC_cum = AC.cumsum()
for _ in range(Q):
    l, r = list(map(int, input().split()))
    print((AC_cum[r - 1] - AC_cum[l - 1]))

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

-import numpy as np - -S = np.array(list("_" + eval(input())), dtype="U") -A = S == "A" -C = S == "C" -AC = A[:-1] & C[1:] -AC_cum = AC.cumsum() -for _ in range(Q): +S = eval(input()) +B = [0] * N +for i in range(N - 1): +    if S[i] == "A" and S[i + 1] == "C": +        B[i] = 1 +for i in range(1, N - 1): +    B[i] += B[i - 1] +for i in range(Q): -    print((AC_cum[r - 1] - AC_cum[l - 1])) +    print((B[r - 2] - B[l - 2]))