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

S =eval(input())

AC_list = [0]*N

count = 0

for i in range(1,N):

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

    count +=1

  AC_list[i] = count



for i in range(Q):

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

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



  

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

S =eval(input())

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

AC_list = [0]*N

count = 0

for i in range(1,N):

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

    count +=1

  AC_list[i] = count



for l, r in length:

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

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

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

+length = [list(map(int, input().split())) for _ in range(Q)] -for i in range(Q): -    l, r = list(map(int, input().split())) +for l, r in length: