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

S = eval(input())

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

S = "0" + S

cnt = []

cnt.append(0)

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

    if (S[i-1:i+1] == "AC"):

        cnt.append(cnt[i-1] + 1)

    else:

        cnt.append(cnt[i-1])

for q in qn:

    ans = cnt[q[1]] - cnt[q[0]-1]

    if S[q[0]-1:q[0]+1] == "AC":

        ans -= 1

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

S = eval(input())

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

S = "0" + S

cnt = [0 for _ in range(N+1)]

# cnt.append(0)

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

    if (S[i-1:i+1] == "AC"):

        cnt[i] = cnt[i-1] + 1

    else:

        cnt[i] = cnt[i-1]

for q in qn:

    l, r = q

#     print(l, cnt[l-2], r, cnt[r-1])

    print((cnt[r] - cnt[l]))

N, Q = list(map(int, input().split()))
S = eval(input())
qn = [list(map(int, input().split())) for _ in range(Q)]
S = "0" + S
cnt = []
cnt.append(0)
for i in range(1, N + 1):
    if S[i - 1 : i + 1] == "AC":
        cnt.append(cnt[i - 1] + 1)
    else:
        cnt.append(cnt[i - 1])
for q in qn:
    ans = cnt[q[1]] - cnt[q[0] - 1]
    if S[q[0] - 1 : q[0] + 1] == "AC":
        ans -= 1
    print(ans)

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

-cnt = [] -cnt.append(0) +cnt = [0 for _ in range(N + 1)] +# cnt.append(0) -        cnt.append(cnt[i - 1] + 1) +        cnt[i] = cnt[i - 1] + 1 -        cnt.append(cnt[i - 1]) +        cnt[i] = cnt[i - 1] -    ans = cnt[q[1]] - cnt[q[0] - 1] -    if S[q[0] - 1 : q[0] + 1] == "AC": -        ans -= 1 -    print(ans) +    l, r = q +    #     print(l, cnt[l-2], r, cnt[r-1]) +    print((cnt[r] - cnt[l]))