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

s = ' ' + eval(input())

heap = [0] * (n + 1)

cnt = 0

for i in range(2, n + 1):

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

        cnt += 1;

    heap[i] = cnt

for i in range(q):

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

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

s = eval(input())

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



cum_sum = [0] * n

for i in range(1, n):

    cum_sum[i] = cum_sum[i - 1]

    if s[i - 1: i + 1] == "AC":

        cum_sum[i] += 1



for i in range(q):

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

n, q = list(map(int, input().split()))
s = eval(input())
q_list = [list(map(int, input().split())) for _ in range(q)]
cum_sum = [0] * n
for i in range(1, n):
    cum_sum[i] = cum_sum[i - 1]
    if s[i - 1 : i + 1] == "AC":
        cum_sum[i] += 1
for i in range(q):
    print((cum_sum[q_list[i][1] - 1] - cum_sum[q_list[i][0] - 1]))

-s = " " + eval(input()) -heap = [0] * (n + 1) -cnt = 0 -for i in range(2, n + 1): -    if s[i - 1] == "A" and s[i] == "C": -        cnt += 1 -    heap[i] = cnt +s = eval(input()) +q_list = [list(map(int, input().split())) for _ in range(q)] +cum_sum = [0] * n +for i in range(1, n): +    cum_sum[i] = cum_sum[i - 1] +    if s[i - 1 : i + 1] == "AC": +        cum_sum[i] += 1 -    l, r = list(map(int, input().split())) -    print((heap[r] - heap[l])) +    print((cum_sum[q_list[i][1] - 1] - cum_sum[q_list[i][0] - 1]))