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

S = eval(input())

left=[]

right=[]

for _ in range(Q):

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

  left.append(l)

  right.append(r)



a = [0]*N

for i in range(1,N):

  if S[i] == "C" and S[i-1] == "A":

    a[i] = a[i-1] + 1

  else:

    a[i] = a[i-1]



#print(a)

ans = []

for j in range(Q):

  ans.append(a[right[j]-1] - a[left[j]-1])



for k in ans:

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

S = eval(input())

L = []

R = []

for i in range(Q):

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

  L.append(l)

  R.append(r)



dp = [0]*N

for j in range(N-1):

  if S[j]=='A' and S[j+1]=='C':

    dp[j+1] = dp[j]+1

  else:

    dp[j+1] = dp[j]



for k in range(Q):

  print((dp[R[k]-1]-dp[L[k]-1]))
N, Q = list(map(int, input().split()))
S = eval(input())
left = []
right = []
for _ in range(Q):
    l, r = list(map(int, input().split()))
    left.append(l)
    right.append(r)
a = [0] * N
for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        a[i] = a[i - 1] + 1
    else:
        a[i] = a[i - 1]
# print(a)
ans = []
for j in range(Q):
    ans.append(a[right[j] - 1] - a[left[j] - 1])
for k in ans:
    print(k)

N, Q = list(map(int, input().split()))
S = eval(input())
L = []
R = []
for i in range(Q):
    l, r = list(map(int, input().split()))
    L.append(l)
    R.append(r)
dp = [0] * N
for j in range(N - 1):
    if S[j] == "A" and S[j + 1] == "C":
        dp[j + 1] = dp[j] + 1
    else:
        dp[j + 1] = dp[j]
for k in range(Q):
    print((dp[R[k] - 1] - dp[L[k] - 1]))

-left = [] -right = [] -for _ in range(Q): +L = [] +R = [] +for i in range(Q): -    left.append(l) -    right.append(r) -a = [0] * N -for i in range(1, N): -    if S[i] == "C" and S[i - 1] == "A": -        a[i] = a[i - 1] + 1 +    L.append(l) +    R.append(r) +dp = [0] * N +for j in range(N - 1): +    if S[j] == "A" and S[j + 1] == "C": +        dp[j + 1] = dp[j] + 1 -        a[i] = a[i - 1] -# print(a) -ans = [] -for j in range(Q): -    ans.append(a[right[j] - 1] - a[left[j] - 1]) -for k in ans: -    print(k) +        dp[j + 1] = dp[j] +for k in range(Q): +    print((dp[R[k] - 1] - dp[L[k] - 1]))