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

ruisekiwa = [0]

lists = []

cnt = 0

S = str(eval(input()))

for t in range(1, N):

    if S[t - 1] == "A" and S[t] == "C":

        cnt += 1

    ruisekiwa.append(cnt)

ruisekiwa.append(cnt)

for i in range(Q):

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

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

    lists.append(ans)

for m in range(len(lists)):

    print((lists[m]))

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

S = str(eval(input()))

count = [0]*(N+1)

lists = []

for i in range(1, N):

    if S[i-1] == "A" and S[i] == "C":

        count[i] = count[i-1] + 1

    else:

        count[i] = count[i-1]

for i in range(Q):

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

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

    lists.append(ans)

for i in range(len(lists)):

    print((lists[i]))

N, Q = list(map(int, input().split()))
ruisekiwa = [0]
lists = []
cnt = 0
S = str(eval(input()))
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = list(map(int, input().split()))
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print((lists[m]))

N, Q = list(map(int, input().split()))
S = str(eval(input()))
count = [0] * (N + 1)
lists = []
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        count[i] = count[i - 1] + 1
    else:
        count[i] = count[i - 1]
for i in range(Q):
    l, r = list(map(int, input().split()))
    ans = count[r - 1] - count[l - 1]
    lists.append(ans)
for i in range(len(lists)):
    print((lists[i]))

-ruisekiwa = [0] +S = str(eval(input())) +count = [0] * (N + 1) -cnt = 0 -S = str(eval(input())) -for t in range(1, N): -    if S[t - 1] == "A" and S[t] == "C": -        cnt += 1 -    ruisekiwa.append(cnt) -ruisekiwa.append(cnt) +for i in range(1, N): +    if S[i - 1] == "A" and S[i] == "C": +        count[i] = count[i - 1] + 1 +    else: +        count[i] = count[i - 1] -    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1] +    ans = count[r - 1] - count[l - 1] -for m in range(len(lists)): -    print((lists[m])) +for i in range(len(lists)): +    print((lists[i]))