import bisect

import re



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

S = eval(input())

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



r = re.compile('AC')

a = [x.start() for x in r.finditer(S)]



if a:

    for q in P:

        p1 = bisect.bisect_left(a, q[0] - 1)

        p2 = bisect.bisect_right(a, q[1] - 2)

        print((p2 - p1))

else:

    for q in P:

        print((0))

import bisect

import re

import sys



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

S = sys.stdin.readline()

P = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]



r = re.compile('AC')

a = [x.start() for x in r.finditer(S)]



if a:

    for q in P:

        p1 = bisect.bisect_left(a, q[0] - 1)

        p2 = bisect.bisect_right(a, q[1] - 2)

        print((p2 - p1))

else:

    for q in P:

        print((0))
import bisect
import re

N, Q = list(map(int, input().split()))
S = eval(input())
P = [list(map(int, input().split())) for _ in range(Q)]
r = re.compile("AC")
a = [x.start() for x in r.finditer(S)]
if a:
    for q in P:
        p1 = bisect.bisect_left(a, q[0] - 1)
        p2 = bisect.bisect_right(a, q[1] - 2)
        print((p2 - p1))
else:
    for q in P:
        print((0))

import bisect
import re
import sys

N, Q = list(map(int, input().split()))
S = sys.stdin.readline()
P = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]
r = re.compile("AC")
a = [x.start() for x in r.finditer(S)]
if a:
    for q in P:
        p1 = bisect.bisect_left(a, q[0] - 1)
        p2 = bisect.bisect_right(a, q[1] - 2)
        print((p2 - p1))
else:
    for q in P:
        print((0))

+import sys -S = eval(input()) -P = [list(map(int, input().split())) for _ in range(Q)] +S = sys.stdin.readline() +P = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]