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

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)



ans = []

for i in range(q):

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

    ans.append(t[r - 1] - t[l - 1])



for a in ans:

    print(a)

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

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)
ans = []
for i in range(q):
    l, r = list(map(int, input().split()))
    ans.append(t[r - 1] - t[l - 1])
for a in ans:
    print(a)

+ans = [] -    print((t[r - 1] - t[l - 1])) +    ans.append(t[r - 1] - t[l - 1]) +for a in ans: +    print(a)