f = lambda : list(map(int,input().split()))



n, q = f()

s = eval(input())



cnt = 0

ln = [0]*n

for i in range(1,n):

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

    cnt += 1

  ln[i] = cnt

for _ in range(q):

  l, r = f()

  print((ln[r-1]-ln[l-1]))
import sys

input = sys.stdin.readline

f = lambda : list(map(int,input().split()))



n, q = f()

s = eval(input())



cnt = 0

ln = [0]*n

for i in range(1,n):

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

    cnt += 1

  ln[i] = cnt

for _ in range(q):

  l, r = f()

  print((ln[r-1]-ln[l-1]))
f = lambda: list(map(int, input().split()))
n, q = f()
s = eval(input())
cnt = 0
ln = [0] * n
for i in range(1, n):
    if s[i - 1 : i + 1] == "AC":
        cnt += 1
    ln[i] = cnt
for _ in range(q):
    l, r = f()
    print((ln[r - 1] - ln[l - 1]))

import sys

input = sys.stdin.readline
f = lambda: list(map(int, input().split()))
n, q = f()
s = eval(input())
cnt = 0
ln = [0] * n
for i in range(1, n):
    if s[i - 1 : i + 1] == "AC":
        cnt += 1
    ln[i] = cnt
for _ in range(q):
    l, r = f()
    print((ln[r - 1] - ln[l - 1]))

+import sys + +input = sys.stdin.readline