import numpy as np

from collections import Counter

import collections

import numpy as np 

from scipy import sqrt, power, exp, log10

from scipy.fftpack import fft, ifft, fftfreq

import tarfile

import re

import os

import glob

from datetime import datetime

import time

import numpy.linalg as LA



round = lambda x:(x*2+1)//2

a,b = list(map(int,input().split()))

S = eval(input())

sub= "AC"

l = np.zeros(len(S)+1)

for i in range(len(S)):

  l[i+1] = l[i] + (1 if S[i:i+2]=="AC" else 0)



for i in range(b):

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

    n = l[t-1]-l[r-1]

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

S = eval(input())

L = [0]*Q 

R = [0]*Q

for q in range(Q):

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

    L[q] = l

    R[q] = r

ans = [0]*Q 

accumulative_count = [0]*(N) 

accumulative_count[0] = 0 

for i in range(1, N, 1): 

    accumulative_count[i] = accumulative_count[i-1]

    if (S[i-1:i] == 'A') & (S[i:i+1] == 'C'):

        accumulative_count[i] = accumulative_count[i-1] + 1

for q in range(Q):

    print((accumulative_count[R[q]-1] - accumulative_count[L[q]-1]))

import numpy as np
from collections import Counter
import collections
import numpy as np
from scipy import sqrt, power, exp, log10
from scipy.fftpack import fft, ifft, fftfreq
import tarfile
import re
import os
import glob
from datetime import datetime
import time
import numpy.linalg as LA

round = lambda x: (x * 2 + 1) // 2
a, b = list(map(int, input().split()))
S = eval(input())
sub = "AC"
l = np.zeros(len(S) + 1)
for i in range(len(S)):
    l[i + 1] = l[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(b):
    r, t = list(map(int, input().split()))
    n = l[t - 1] - l[r - 1]
    print((int(n)))

N, Q = list(map(int, input().split()))
S = eval(input())
L = [0] * Q
R = [0] * Q
for q in range(Q):
    l, r = list(map(int, input().split()))
    L[q] = l
    R[q] = r
ans = [0] * Q
accumulative_count = [0] * (N)
accumulative_count[0] = 0
for i in range(1, N, 1):
    accumulative_count[i] = accumulative_count[i - 1]
    if (S[i - 1 : i] == "A") & (S[i : i + 1] == "C"):
        accumulative_count[i] = accumulative_count[i - 1] + 1
for q in range(Q):
    print((accumulative_count[R[q] - 1] - accumulative_count[L[q] - 1]))

-import numpy as np -from collections import Counter -import collections -import numpy as np -from scipy import sqrt, power, exp, log10 -from scipy.fftpack import fft, ifft, fftfreq -import tarfile -import re -import os -import glob -from datetime import datetime -import time -import numpy.linalg as LA - -round = lambda x: (x * 2 + 1) // 2 -a, b = list(map(int, input().split())) +N, Q = list(map(int, input().split())) -sub = "AC" -l = np.zeros(len(S) + 1) -for i in range(len(S)): -    l[i + 1] = l[i] + (1 if S[i : i + 2] == "AC" else 0) -for i in range(b): -    r, t = list(map(int, input().split())) -    n = l[t - 1] - l[r - 1] -    print((int(n))) +L = [0] * Q +R = [0] * Q +for q in range(Q): +    l, r = list(map(int, input().split())) +    L[q] = l +    R[q] = r +ans = [0] * Q +accumulative_count = [0] * (N) +accumulative_count[0] = 0 +for i in range(1, N, 1): +    accumulative_count[i] = accumulative_count[i - 1] +    if (S[i - 1 : i] == "A") & (S[i : i + 1] == "C"): +        accumulative_count[i] = accumulative_count[i - 1] + 1 +for q in range(Q): +    print((accumulative_count[R[q] - 1] - accumulative_count[L[q] - 1]))