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

S = eval(input())

s = [0]*N

A = []

for n in range(N-1):

    if S[n] + S[n+1] == 'AC':

        s[n+1] = s[n] + 1

    else:

        s[n+1] = s[n]

for q in range(Q):

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

    A.append(s[r-1] - s[l-1])

for a in A:

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

S = eval(input())

s = [0]*(N+1)

for n in range(N):

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

        s[n+1] = s[n] + 1

    else:

        s[n+1] = s[n]

A = []

for q in range(Q):

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

    l -= 1

    r -= 1

    A.append(s[r]-s[l])

for a in A:

    print(a)
N, Q = list(map(int, input().split()))
S = eval(input())
s = [0] * N
A = []
for n in range(N - 1):
    if S[n] + S[n + 1] == "AC":
        s[n + 1] = s[n] + 1
    else:
        s[n + 1] = s[n]
for q in range(Q):
    l, r = list(map(int, input().split()))
    A.append(s[r - 1] - s[l - 1])
for a in A:
    print(a)

N, Q = list(map(int, input().split()))
S = eval(input())
s = [0] * (N + 1)
for n in range(N):
    if n + 1 < N and S[n] == "A" and S[n + 1] == "C":
        s[n + 1] = s[n] + 1
    else:
        s[n + 1] = s[n]
A = []
for q in range(Q):
    l, r = list(map(int, input().split()))
    l -= 1
    r -= 1
    A.append(s[r] - s[l])
for a in A:
    print(a)

-s = [0] * N -A = [] -for n in range(N - 1): -    if S[n] + S[n + 1] == "AC": +s = [0] * (N + 1) +for n in range(N): +    if n + 1 < N and S[n] == "A" and S[n + 1] == "C": +A = [] -    A.append(s[r - 1] - s[l - 1]) +    l -= 1 +    r -= 1 +    A.append(s[r] - s[l])