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]))

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

s = eval(input())

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



li = [0] * n

# print(s[0:2])

for i in range(n - 1):

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

    li[i+1] += li[i] + 1

  else:

    li[i+1] = li[i]

# print(li)

for j in lr:

  print((li[j[1]-1] - li[j[0]-1]))
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]))

n, q = list(map(int, input().split()))
s = eval(input())
lr = [list(map(int, input().split())) for _ in range(q)]
li = [0] * n
# print(s[0:2])
for i in range(n - 1):
    if s[i : i + 2] == "AC":
        li[i + 1] += li[i] + 1
    else:
        li[i + 1] = li[i]
# print(li)
for j in lr:
    print((li[j[1] - 1] - li[j[0] - 1]))

-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])) +n, q = list(map(int, input().split())) +s = eval(input()) +lr = [list(map(int, input().split())) for _ in range(q)] +li = [0] * n +# print(s[0:2]) +for i in range(n - 1): +    if s[i : i + 2] == "AC": +        li[i + 1] += li[i] + 1 +    else: +        li[i + 1] = li[i] +# print(li) +for j in lr: +    print((li[j[1] - 1] - li[j[0] - 1]))