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

S = eval(input())

l, r = [], []

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]))
# ABC122 C-GetAC



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

S = eval(input())

lr = []

for _ in range(Q):

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

    

ArrayAC = [0]*(N)

for j, i in enumerate(S):

    if j == N-1:

        break

    

    if S[j:j+2] == "AC":

        ArrayAC[j+1] = ArrayAC[j] + 1

    else:

        ArrayAC[j+1] = ArrayAC[j]

        

        

for i, j in lr:

    print((ArrayAC[j-1] - ArrayAC[i-1]))
N, Q = list(map(int, input().split()))
S = eval(input())
l, r = [], []
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]))

# ABC122 C-GetAC
N, Q = list(map(int, input().split()))
S = eval(input())
lr = []
for _ in range(Q):
    lr.append(list(map(int, input().split())))
ArrayAC = [0] * (N)
for j, i in enumerate(S):
    if j == N - 1:
        break
    if S[j : j + 2] == "AC":
        ArrayAC[j + 1] = ArrayAC[j] + 1
    else:
        ArrayAC[j + 1] = ArrayAC[j]
for i, j in lr:
    print((ArrayAC[j - 1] - ArrayAC[i - 1]))

+# ABC122 C-GetAC -l, r = [], [] -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])) +lr = [] +for _ in range(Q): +    lr.append(list(map(int, input().split()))) +ArrayAC = [0] * (N) +for j, i in enumerate(S): +    if j == N - 1: +        break +    if S[j : j + 2] == "AC": +        ArrayAC[j + 1] = ArrayAC[j] + 1 +    else: +        ArrayAC[j + 1] = ArrayAC[j] +for i, j in lr: +    print((ArrayAC[j - 1] - ArrayAC[i - 1]))