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

S = eval(input())

t = [0] * (N + 1)

for i in range(N):

    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

for i in range(Q):

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

    print((t[r-1] - t[l-1]))

from sys import stdin



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

s=eval(input())

l = [stdin.readline().rstrip().split() for _ in range(q)]



t=[0]*(n+1)

for i in range(n):

    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

for j,k in l:

    print((t[int(k)-1]-t[int(j)-1]))
N, Q = list(map(int, input().split()))
S = eval(input())
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = list(map(int, input().split()))
    print((t[r - 1] - t[l - 1]))

from sys import stdin

n, q = list(map(int, input().split()))
s = eval(input())
l = [stdin.readline().rstrip().split() for _ in range(q)]
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)
for j, k in l:
    print((t[int(k) - 1] - t[int(j) - 1]))

-N, Q = list(map(int, input().split())) -S = eval(input()) -t = [0] * (N + 1) -for i in range(N): -    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0) -for i in range(Q): -    l, r = list(map(int, input().split())) -    print((t[r - 1] - t[l - 1])) +from sys import stdin + +n, q = list(map(int, input().split())) +s = eval(input()) +l = [stdin.readline().rstrip().split() for _ in range(q)] +t = [0] * (n + 1) +for i in range(n): +    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) +for j, k in l: +    print((t[int(k) - 1] - t[int(j) - 1]))