import bisect

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

s = eval(input())

cnt = 0

apoint = []

cpoint = []

for i in range(len(s) - 1):

    if s[i] + s[i + 1] == 'AC':

        cnt += 1

        apoint.append(i)

        cpoint.append(i)

# print('cnt:', cnt)

# print('acpoint:', apoint)

for i in range(q):

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

    l, r = l - 1, r - 1

    left = bisect.bisect_left(apoint, l)

    right = bisect.bisect_left(cpoint, r)

    print((right - left))

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

S = eval(input())

t = [0] * (N + 1)

for i in range(N):

	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

for i in range(Q):

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

	print((t[r-1] - t[l-1]))

import bisect

n, q = list(map(int, input().split()))
s = eval(input())
cnt = 0
apoint = []
cpoint = []
for i in range(len(s) - 1):
    if s[i] + s[i + 1] == "AC":
        cnt += 1
        apoint.append(i)
        cpoint.append(i)
# print('cnt:', cnt)
# print('acpoint:', apoint)
for i in range(q):
    l, r = list(map(int, input().split()))
    l, r = l - 1, r - 1
    left = bisect.bisect_left(apoint, l)
    right = bisect.bisect_left(cpoint, r)
    print((right - left))

N, Q = list(map(int, input().split()))
S = eval(input())
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = list(map(int, input().split()))
    print((t[r - 1] - t[l - 1]))

-import bisect - -n, q = list(map(int, input().split())) -s = eval(input()) -cnt = 0 -apoint = [] -cpoint = [] -for i in range(len(s) - 1): -    if s[i] + s[i + 1] == "AC": -        cnt += 1 -        apoint.append(i) -        cpoint.append(i) -# print('cnt:', cnt) -# print('acpoint:', apoint) -for i in range(q): +N, Q = list(map(int, input().split())) +S = eval(input()) +t = [0] * (N + 1) +for i in range(N): +    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0) +for i in range(Q): -    l, r = l - 1, r - 1 -    left = bisect.bisect_left(apoint, l) -    right = bisect.bisect_left(cpoint, r) -    print((right - left)) +    print((t[r - 1] - t[l - 1]))