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

str = eval(input())

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



ans = [0 for _ in range(N)]

for i in range(1, N):

    if (str[i-1] == "A") and (str[i] == "C"):

        ans[i] = ans[i-1] + 1

    else:

        ans[i] = ans[i-1]



for l1, l2 in length:

    # print(ans)

    print((ans[l2-1] - ans[l1-1]))

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

str = eval(input())

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



ans = [0 for _ in range(N)]

for i in range(1, N):

    if (str[i-1] == "A"):

        if (str[i] == "C"):

            ans[i] = ans[i-1] + 1

        else:

            ans[i] = ans[i-1]

    else:

        ans[i] = ans[i-1]

        if i != N-1:

            ans[i+1] = ans[i-1]

        i += 1



for l1, l2 in length:

    # print(ans)

    print((ans[l2-1] - ans[l1-1]))

N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i - 1] == "A") and (str[i] == "C"):
        ans[i] = ans[i - 1] + 1
    else:
        ans[i] = ans[i - 1]
for l1, l2 in length:
    # print(ans)
    print((ans[l2 - 1] - ans[l1 - 1]))

N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
    if str[i - 1] == "A":
        if str[i] == "C":
            ans[i] = ans[i - 1] + 1
        else:
            ans[i] = ans[i - 1]
    else:
        ans[i] = ans[i - 1]
        if i != N - 1:
            ans[i + 1] = ans[i - 1]
        i += 1
for l1, l2 in length:
    # print(ans)
    print((ans[l2 - 1] - ans[l1 - 1]))

-    if (str[i - 1] == "A") and (str[i] == "C"): -        ans[i] = ans[i - 1] + 1 +    if str[i - 1] == "A": +        if str[i] == "C": +            ans[i] = ans[i - 1] + 1 +        else: +            ans[i] = ans[i - 1] +        if i != N - 1: +            ans[i + 1] = ans[i - 1] +        i += 1