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]))
import sys

import math



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

S = eval(input())

a = [0 for _ in range(N)]



for i in range(1, N):

    if S[i-1]+S[i] == "AC":

        a[i] += 1 + a[i-1]

    else:

        a[i] += a[i-1]



for _ in range(Q):

    l, r = list(map(int, sys.stdin.readline().strip().split()))

    print((a[r-1] - a[l-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]))

import sys
import math

N, Q = list(map(int, input().split()))
S = eval(input())
a = [0 for _ in range(N)]
for i in range(1, N):
    if S[i - 1] + S[i] == "AC":
        a[i] += 1 + a[i - 1]
    else:
        a[i] += a[i - 1]
for _ in range(Q):
    l, r = list(map(int, sys.stdin.readline().strip().split()))
    print((a[r - 1] - a[l - 1]))

+import sys +import math + -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])) +a = [0 for _ in range(N)] +for i in range(1, N): +    if S[i - 1] + S[i] == "AC": +        a[i] += 1 + a[i - 1] +    else: +        a[i] += a[i - 1] +for _ in range(Q): +    l, r = list(map(int, sys.stdin.readline().strip().split())) +    print((a[r - 1] - a[l - 1]))