n,q=list(map(int,input().split()))

S=eval(input())

cnt=[0]*n



for i in range(1, n):

    s=S[i-1]+S[i]

    if s=="AC":

        cnt[i]+=1



for i in range(1, n):

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



for _ in range(q):

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

    ans=cnt[r-1]-cnt[l-1]

    print(ans)
from itertools import accumulate

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

S = "?" + input()

query = (tuple(map(int, input().split())) for _ in range(Q))



cnt = [0] * (N+1)

for i in range(N):

    if S[i] + S[i + 1] == "AC":

        cnt[i + 1] += 1



cnt = tuple(accumulate(cnt))



ans = (cnt[r] - cnt[l] for l, r in query)

print(*ans, sep="\n")

n, q = list(map(int, input().split()))
S = eval(input())
cnt = [0] * n
for i in range(1, n):
    s = S[i - 1] + S[i]
    if s == "AC":
        cnt[i] += 1
for i in range(1, n):
    cnt[i] += cnt[i - 1]
for _ in range(q):
    l, r = list(map(int, input().split()))
    ans = cnt[r - 1] - cnt[l - 1]
    print(ans)

from itertools import accumulate

N, Q = map(int, input().split())
S = "?" + input()
query = (tuple(map(int, input().split())) for _ in range(Q))
cnt = [0] * (N + 1)
for i in range(N):
    if S[i] + S[i + 1] == "AC":
        cnt[i + 1] += 1
cnt = tuple(accumulate(cnt))
ans = (cnt[r] - cnt[l] for l, r in query)
print(*ans, sep="\n")

-n, q = list(map(int, input().split())) -S = eval(input()) -cnt = [0] * n -for i in range(1, n): -    s = S[i - 1] + S[i] -    if s == "AC": -        cnt[i] += 1 -for i in range(1, n): -    cnt[i] += cnt[i - 1] -for _ in range(q): -    l, r = list(map(int, input().split())) -    ans = cnt[r - 1] - cnt[l - 1] -    print(ans) +from itertools import accumulate + +N, Q = map(int, input().split()) +S = "?" + input() +query = (tuple(map(int, input().split())) for _ in range(Q)) +cnt = [0] * (N + 1) +for i in range(N): +    if S[i] + S[i + 1] == "AC": +        cnt[i + 1] += 1 +cnt = tuple(accumulate(cnt)) +ans = (cnt[r] - cnt[l] for l, r in query) +print(*ans, sep="\n")