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

S = eval(input())

  

ac_sum = [0]*N

for i in range(N):

  if S[max(i-1,0):i+1] == "AC":

    ac_sum[i] = ac_sum[max(i-1,0)] + 1

  else:

    ac_sum[i] = ac_sum[max(i-1,0)]



for _ in range(Q):

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

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



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

S = eval(input())



cnt = [0]*N

i = 0

while i < N-1:

    if S[i:i+2] == "AC":

        cnt[i] += 1

        i += 1

    i += 1



AS = [0]*(N+1)

for i in range(1, N+1):

    AS[i] = AS[i-1] + cnt[i-1]



for i in range(Q):

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

    ans = AS[r-1] - AS[l-1]

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

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

-ac_sum = [0] * N -for i in range(N): -    if S[max(i - 1, 0) : i + 1] == "AC": -        ac_sum[i] = ac_sum[max(i - 1, 0)] + 1 -    else: -        ac_sum[i] = ac_sum[max(i - 1, 0)] -for _ in range(Q): +cnt = [0] * N +i = 0 +while i < N - 1: +    if S[i : i + 2] == "AC": +        cnt[i] += 1 +        i += 1 +    i += 1 +AS = [0] * (N + 1) +for i in range(1, N + 1): +    AS[i] = AS[i - 1] + cnt[i - 1] +for i in range(Q): -    print((ac_sum[r - 1] - ac_sum[l - 1])) +    ans = AS[r - 1] - AS[l - 1] +    print(ans)