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

s = eval(input())

t = [0] * (n + 1)

nl = set(range(n))

for i in nl:

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

ql = set(range(q))

for i in ql:

    l1, l2 = list(map(int, input().split()))

    ans = t[l2-1] - t[l1-1]

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

S = eval(input())

lr = [list(map(int, input().split())) for _ in range(Q)]

s = [0] * N

for i in range(N-1):

    if S[i:i + 2] == 'AC':

        s[i+1] = s[i] + 1

    else:

        s[i+1] = s[i]

for l, r in lr:

    print((s[r-1] - s[l-1]))
n, q = list(map(int, input().split()))
s = eval(input())
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = list(map(int, input().split()))
    ans = t[l2 - 1] - t[l1 - 1]
    print(ans)

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

-n, q = list(map(int, input().split())) -s = eval(input()) -t = [0] * (n + 1) -nl = set(range(n)) -for i in nl: -    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) -ql = set(range(q)) -for i in ql: -    l1, l2 = list(map(int, input().split())) -    ans = t[l2 - 1] - t[l1 - 1] -    print(ans) +N, Q = list(map(int, input().split())) +S = eval(input()) +lr = [list(map(int, input().split())) for _ in range(Q)] +s = [0] * N +for i in range(N - 1): +    if S[i : i + 2] == "AC": +        s[i + 1] = s[i] + 1 +    else: +        s[i + 1] = s[i] +for l, r in lr: +    print((s[r - 1] - s[l - 1]))