# ABC122C - GeT AC

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

s = input().rstrip()

arr = [list(map(int, input().rstrip().split())) for _ in range(q)]

cnt = [0] * (n + 1)

for i in range(n):

    if s[i : i + 2] == "AC":

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

    else:

        cnt[i + 1] = cnt[i]

for i, j in arr:

    print((cnt[j - 1] - cnt[i - 1]))

# ABC122C - GeT AC

import sys

input = sys.stdin.readline





def main():

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

    s = input().rstrip()

    arr = tuple(tuple(map(int, input().split())) for _ in range(q))

    cnt = [0] * (n + 1)

    for i in range(n):

        if s[i : i + 2] == "AC":

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

        else:

            cnt[i + 1] = cnt[i]

    for i, j in arr:

        print((cnt[j - 1] - cnt[i - 1]))





if __name__ == "__main__":

    main()
# ABC122C - GeT AC
n, q = list(map(int, input().rstrip().split()))
s = input().rstrip()
arr = [list(map(int, input().rstrip().split())) for _ in range(q)]
cnt = [0] * (n + 1)
for i in range(n):
    if s[i : i + 2] == "AC":
        cnt[i + 1] = cnt[i] + 1
    else:
        cnt[i + 1] = cnt[i]
for i, j in arr:
    print((cnt[j - 1] - cnt[i - 1]))

# ABC122C - GeT AC
import sys

input = sys.stdin.readline


def main():
    n, q = list(map(int, input().rstrip().split()))
    s = input().rstrip()
    arr = tuple(tuple(map(int, input().split())) for _ in range(q))
    cnt = [0] * (n + 1)
    for i in range(n):
        if s[i : i + 2] == "AC":
            cnt[i + 1] = cnt[i] + 1
        else:
            cnt[i + 1] = cnt[i]
    for i, j in arr:
        print((cnt[j - 1] - cnt[i - 1]))


if __name__ == "__main__":
    main()

-n, q = list(map(int, input().rstrip().split())) -s = input().rstrip() -arr = [list(map(int, input().rstrip().split())) for _ in range(q)] -cnt = [0] * (n + 1) -for i in range(n): -    if s[i : i + 2] == "AC": -        cnt[i + 1] = cnt[i] + 1 -    else: -        cnt[i + 1] = cnt[i] -for i, j in arr: -    print((cnt[j - 1] - cnt[i - 1])) +import sys + +input = sys.stdin.readline + + +def main(): +    n, q = list(map(int, input().rstrip().split())) +    s = input().rstrip() +    arr = tuple(tuple(map(int, input().split())) for _ in range(q)) +    cnt = [0] * (n + 1) +    for i in range(n): +        if s[i : i + 2] == "AC": +            cnt[i + 1] = cnt[i] + 1 +        else: +            cnt[i + 1] = cnt[i] +    for i, j in arr: +        print((cnt[j - 1] - cnt[i - 1])) + + +if __name__ == "__main__": +    main()