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

S = eval(input())

s = [0]



for i in range(N):

  s.append(s[-1]+(1 if S[i:i+2]=='AC' else 0))



for i in range(Q):

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

  print((s[r-1]-s[l-1]))
import numpy as np

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

S = eval(input())

T = (N+1)*[0]



for n in range(N):

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

    T[n+1]+=1



T = np.cumsum(T)



for q 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())
s = [0]
for i in range(N):
    s.append(s[-1] + (1 if S[i : i + 2] == "AC" else 0))
for i in range(Q):
    l, r = list(map(int, input().split()))
    print((s[r - 1] - s[l - 1]))

import numpy as np

N, Q = list(map(int, input().split()))
S = eval(input())
T = (N + 1) * [0]
for n in range(N):
    if S[n : n + 2] == "AC":
        T[n + 1] += 1
T = np.cumsum(T)
for q in range(Q):
    l, r = list(map(int, input().split()))
    print((T[r - 1] - T[l - 1]))

+import numpy as np + -s = [0] -for i in range(N): -    s.append(s[-1] + (1 if S[i : i + 2] == "AC" else 0)) -for i in range(Q): +T = (N + 1) * [0] +for n in range(N): +    if S[n : n + 2] == "AC": +        T[n + 1] += 1 +T = np.cumsum(T) +for q in range(Q): -    print((s[r - 1] - s[l - 1])) +    print((T[r - 1] - T[l - 1]))