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

S = eval(input())

Q_lst = []

for i in range(Q):

    Q_lst.append(list(map(int,input().split())))



ruiseki_lst = [0 for i in range(N)]



ruiseki_lst[0] = 0

for i in range(1,N):

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

        ruiseki_lst[i] = ruiseki_lst[i-1] + 1

    else:

        ruiseki_lst[i] = ruiseki_lst[i - 1]



for q in Q_lst:

    left = q[0]-1

    right = q[1]-1

    print((ruiseki_lst[right] - ruiseki_lst[left]))
N ,Q = list(map(int,input().split()))

S = eval(input())

lst = []

for i in range(Q):

    s,e = list(map(int,input().split()))

    lst.append([s-1,e-1])

#print(lst)



cum = [0]*N

for i in range(1,N):

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

        cum[i] = cum[i-1] + 1

    else:

        cum[i] = cum[i - 1]



for v in lst:

    print((cum[v[1]] - cum[v[0]]))
N, Q = list(map(int, input().split()))
S = eval(input())
Q_lst = []
for i in range(Q):
    Q_lst.append(list(map(int, input().split())))
ruiseki_lst = [0 for i in range(N)]
ruiseki_lst[0] = 0
for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        ruiseki_lst[i] = ruiseki_lst[i - 1] + 1
    else:
        ruiseki_lst[i] = ruiseki_lst[i - 1]
for q in Q_lst:
    left = q[0] - 1
    right = q[1] - 1
    print((ruiseki_lst[right] - ruiseki_lst[left]))

N, Q = list(map(int, input().split()))
S = eval(input())
lst = []
for i in range(Q):
    s, e = list(map(int, input().split()))
    lst.append([s - 1, e - 1])
# print(lst)
cum = [0] * N
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        cum[i] = cum[i - 1] + 1
    else:
        cum[i] = cum[i - 1]
for v in lst:
    print((cum[v[1]] - cum[v[0]]))

-Q_lst = [] +lst = [] -    Q_lst.append(list(map(int, input().split()))) -ruiseki_lst = [0 for i in range(N)] -ruiseki_lst[0] = 0 +    s, e = list(map(int, input().split())) +    lst.append([s - 1, e - 1]) +# print(lst) +cum = [0] * N -    if S[i] == "C" and S[i - 1] == "A": -        ruiseki_lst[i] = ruiseki_lst[i - 1] + 1 +    if S[i - 1] == "A" and S[i] == "C": +        cum[i] = cum[i - 1] + 1 -        ruiseki_lst[i] = ruiseki_lst[i - 1] -for q in Q_lst: -    left = q[0] - 1 -    right = q[1] - 1 -    print((ruiseki_lst[right] - ruiseki_lst[left])) +        cum[i] = cum[i - 1] +for v in lst: +    print((cum[v[1]] - cum[v[0]]))