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

S = eval(input())



sum_table = [0] * (N+1)



for i in range(N):

    sum_table[i+1] = sum_table[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q):

    left, right = list(map(int, input().split()))

    print((sum_table[right-1] - sum_table[left-1]))



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

S = eval(input())



sum_table = [0] * (N+1)



for i in range(N):

    sum_table[i+1] = sum_table[i] + (1 if S[i:i+2] == "AC" else 0)



ans_table = []

for i in range(Q):

    left, right = list(map(int, input().split()))

    ans_table.append(sum_table[right-1] - sum_table[left-1])



for i in range(len(ans_table)):

    print((ans_table[i]))

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

N, Q = list(map(int, input().split()))
S = eval(input())
sum_table = [0] * (N + 1)
for i in range(N):
    sum_table[i + 1] = sum_table[i] + (1 if S[i : i + 2] == "AC" else 0)
ans_table = []
for i in range(Q):
    left, right = list(map(int, input().split()))
    ans_table.append(sum_table[right - 1] - sum_table[left - 1])
for i in range(len(ans_table)):
    print((ans_table[i]))

+ans_table = [] -    print((sum_table[right - 1] - sum_table[left - 1])) +    ans_table.append(sum_table[right - 1] - sum_table[left - 1]) +for i in range(len(ans_table)): +    print((ans_table[i]))