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

S = list(eval(input()))

S.append(0)

par = [0]*(N+1)#par[0]は無視

Ans = []

for i in range(N):

        par [i+1]=par[i]+(1 if (S[i]=='A') & (S[i+1]=='C') else 0)

for i in range(Q):

        x,y = list(map(int,input().split()))

        print((par[y-1]-par[x-1]))

        

n,q = list(map(int,input().split()))

s = eval(input())

s += ' '

ruiseki = []

i = 0

while i<n:

    if s[i]+s[i+1]=='AC':

        ruiseki.append('')

        ruiseki.append('AC')

        i= i+1

    else:

        ruiseki.append(s[i])

    i+=1

t = [0] * (n+1)

for i in range(n):

    if ruiseki[i] == 'AC':

        t[i+1] = t[i]+1

    else:

        t[i+1] = t[i]

for i in range(q):

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

    print((t[r]-t[l])) 
N, Q = list(map(int, input().split()))
S = list(eval(input()))
S.append(0)
par = [0] * (N + 1)  # par[0]は無視
Ans = []
for i in range(N):
    par[i + 1] = par[i] + (1 if (S[i] == "A") & (S[i + 1] == "C") else 0)
for i in range(Q):
    x, y = list(map(int, input().split()))
    print((par[y - 1] - par[x - 1]))

n, q = list(map(int, input().split()))
s = eval(input())
s += " "
ruiseki = []
i = 0
while i < n:
    if s[i] + s[i + 1] == "AC":
        ruiseki.append("")
        ruiseki.append("AC")
        i = i + 1
    else:
        ruiseki.append(s[i])
    i += 1
t = [0] * (n + 1)
for i in range(n):
    if ruiseki[i] == "AC":
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]
for i in range(q):
    l, r = list(map(int, input().split()))
    print((t[r] - t[l]))

-N, Q = list(map(int, input().split())) -S = list(eval(input())) -S.append(0) -par = [0] * (N + 1)  # par[0]は無視 -Ans = [] -for i in range(N): -    par[i + 1] = par[i] + (1 if (S[i] == "A") & (S[i + 1] == "C") else 0) -for i in range(Q): -    x, y = list(map(int, input().split())) -    print((par[y - 1] - par[x - 1])) +n, q = list(map(int, input().split())) +s = eval(input()) +s += " " +ruiseki = [] +i = 0 +while i < n: +    if s[i] + s[i + 1] == "AC": +        ruiseki.append("") +        ruiseki.append("AC") +        i = i + 1 +    else: +        ruiseki.append(s[i]) +    i += 1 +t = [0] * (n + 1) +for i in range(n): +    if ruiseki[i] == "AC": +        t[i + 1] = t[i] + 1 +    else: +        t[i + 1] = t[i] +for i in range(q): +    l, r = list(map(int, input().split())) +    print((t[r] - t[l]))