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

S = eval(input())

LR = [list([int(x)-1 for x in input().split()]) for _ in range(Q)]



L = [0 for _ in range(N)]

R = [0 for _ in range(N)]



for i in range(1,N):

    if S[i-1:i+1] == 'AC':

        if i == 0:

            L[i] = 1

        else:

            L[i] = L[i-1] + 1

    else:

        if i > 0:

            L[i] = L[i-1]



for i in range(Q):

    Li = LR[i][0]

    Ri = LR[i][1]



    print((L[Ri] - L[Li]))







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

S = eval(input())

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



c = [0] * (N+1)

for i in range(0, N):

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

        c[i+1] = c[i] + 1

    else:

        c[i+1] = c[i]



for i in range(Q):

    print((c[lr[i][1]-1] - c[lr[i][0]-1]))



N, Q = list(map(int, input().split()))
S = eval(input())
LR = [list([int(x) - 1 for x in input().split()]) for _ in range(Q)]
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(1, N):
    if S[i - 1 : i + 1] == "AC":
        if i == 0:
            L[i] = 1
        else:
            L[i] = L[i - 1] + 1
    else:
        if i > 0:
            L[i] = L[i - 1]
for i in range(Q):
    Li = LR[i][0]
    Ri = LR[i][1]
    print((L[Ri] - L[Li]))

N, Q = list(map(int, input().split()))
S = eval(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
c = [0] * (N + 1)
for i in range(0, N):
    if i + 1 < N and S[i] == "A" and S[i + 1] == "C":
        c[i + 1] = c[i] + 1
    else:
        c[i + 1] = c[i]
for i in range(Q):
    print((c[lr[i][1] - 1] - c[lr[i][0] - 1]))

-LR = [list([int(x) - 1 for x in input().split()]) for _ in range(Q)] -L = [0 for _ in range(N)] -R = [0 for _ in range(N)] -for i in range(1, N): -    if S[i - 1 : i + 1] == "AC": -        if i == 0: -            L[i] = 1 -        else: -            L[i] = L[i - 1] + 1 +lr = [list(map(int, input().split())) for _ in range(Q)] +c = [0] * (N + 1) +for i in range(0, N): +    if i + 1 < N and S[i] == "A" and S[i + 1] == "C": +        c[i + 1] = c[i] + 1 -        if i > 0: -            L[i] = L[i - 1] +        c[i + 1] = c[i] -    Li = LR[i][0] -    Ri = LR[i][1] -    print((L[Ri] - L[Li])) +    print((c[lr[i][1] - 1] - c[lr[i][0] - 1]))