n, q = (int(x) for x in 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 = (int(x) for x in input().split())

  print((t[r-1]-t[l-1]))
n, q = (int(x) for x in input().split())

s = (eval(input()))

l = [0]*q

r = [0]*q

t = [0]*n

for i in range(q):

    l[i], r[i] = (int(x) for x in input().split())



for i in range(n-1):

    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)



for i in range(q):

    print((t[r[i]-1] - t[l[i]-1]))
n, q = (int(x) for x in 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 = (int(x) for x in input().split())
    print((t[r - 1] - t[l - 1]))

n, q = (int(x) for x in input().split())
s = eval(input())
l = [0] * q
r = [0] * q
t = [0] * n
for i in range(q):
    l[i], r[i] = (int(x) for x in input().split())
for i in range(n - 1):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)
for i in range(q):
    print((t[r[i] - 1] - t[l[i] - 1]))

-t = [0] * (n + 1) -for i in range(n): +l = [0] * q +r = [0] * q +t = [0] * n +for i in range(q): +    l[i], r[i] = (int(x) for x in input().split()) +for i in range(n - 1): -    l, r = (int(x) for x in input().split()) -    print((t[r - 1] - t[l - 1])) +    print((t[r[i] - 1] - t[l[i] - 1]))