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]))



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

S = eval(input())



n = len(S)

ctr = [0] * n

for i in range(n):

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

        ctr[i] = 1



cumsum = [0] * (n + 1)

for i in range(n):

    cumsum[i + 1] = cumsum[i] + ctr[i]



for _ in range(Q):

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

    print((cumsum[r] - cumsum[l - 1] - ctr[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]))

N, Q = list(map(int, input().split()))
S = eval(input())
n = len(S)
ctr = [0] * n
for i in range(n):
    if i > 0 and S[i - 1] == "A" and S[i] == "C":
        ctr[i] = 1
cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i + 1] = cumsum[i] + ctr[i]
for _ in range(Q):
    l, r = list(map(int, input().split()))
    print((cumsum[r] - cumsum[l - 1] - ctr[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])) +n = len(S) +ctr = [0] * n +for i in range(n): +    if i > 0 and S[i - 1] == "A" and S[i] == "C": +        ctr[i] = 1 +cumsum = [0] * (n + 1) +for i in range(n): +    cumsum[i + 1] = cumsum[i] + ctr[i] +for _ in range(Q): +    l, r = list(map(int, input().split())) +    print((cumsum[r] - cumsum[l - 1] - ctr[l - 1]))