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

S = eval(input())

s = [0]*(n+1)

for i in range(1,n):

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

		s[i] = 1

for i in range(1,n):

	s[i] += s[i-1]

for i in range(q):

	l,r = [int(j)-1 for j in input().split()]

	print((s[r]-s[l]))  
n,q = list(map(int,input().split()))

S = eval(input())

b = [0]*(n+1)

for i in range(n-1):

    if S[i] == 'A' and S[i+1] == 'C':

       b[i+1] += 1

from itertools import accumulate

b = list(accumulate(b))

#print(b)

for i in range(q):

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

    print((b[r-1]-b[l-1]))
n, q = list(map(int, input().split()))
S = eval(input())
s = [0] * (n + 1)
for i in range(1, n):
    if S[i - 1] == "A" and S[i] == "C":
        s[i] = 1
for i in range(1, n):
    s[i] += s[i - 1]
for i in range(q):
    l, r = [int(j) - 1 for j in input().split()]
    print((s[r] - s[l]))

n, q = list(map(int, input().split()))
S = eval(input())
b = [0] * (n + 1)
for i in range(n - 1):
    if S[i] == "A" and S[i + 1] == "C":
        b[i + 1] += 1
from itertools import accumulate

b = list(accumulate(b))
# print(b)
for i in range(q):
    l, r = list(map(int, input().split()))
    print((b[r - 1] - b[l - 1]))

-s = [0] * (n + 1) -for i in range(1, n): -    if S[i - 1] == "A" and S[i] == "C": -        s[i] = 1 -for i in range(1, n): -    s[i] += s[i - 1] +b = [0] * (n + 1) +for i in range(n - 1): +    if S[i] == "A" and S[i + 1] == "C": +        b[i + 1] += 1 +from itertools import accumulate + +b = list(accumulate(b)) +# print(b) -    l, r = [int(j) - 1 for j in input().split()] -    print((s[r] - s[l])) +    l, r = list(map(int, input().split())) +    print((b[r - 1] - b[l - 1]))