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

S = eval(input())



cumu = [0]*(N+1)



for i in range(N):

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



for i in range(Q):

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

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

S = eval(input())

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



comu = [0]*(N+1)



for i in range(N):

    if S[i:i+2] == 'AC':

        comu[i+1] = comu[i] + 1

    else:

        comu[i+1] = comu[i]



for l,r in list:

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

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

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