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

s = eval(input())

ll = list(list(map(int, input().split())) for _ in range(q))



acl = [0] * n

cnt = 0

for i in range(1, n):

    if s[i-1:i+1] == 'AC':

        cnt += 1

    acl[i] = cnt



for i in range(q):

    l = ll[i][0]

    r = ll[i][1]

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

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

s = eval(input())

sl = [0]

for i in range(1, n):

    if s[i-1:i+1] == 'AC':

        sl.append(sl[i-1]+1)

    else:

        sl.append(sl[i-1])



for _ in range(q):

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

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

n, q = list(map(int, input().split()))
s = eval(input())
ll = list(list(map(int, input().split())) for _ in range(q))
acl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i - 1 : i + 1] == "AC":
        cnt += 1
    acl[i] = cnt
for i in range(q):
    l = ll[i][0]
    r = ll[i][1]
    print((acl[r - 1] - acl[l - 1]))

n, q = list(map(int, input().split()))
s = eval(input())
sl = [0]
for i in range(1, n):
    if s[i - 1 : i + 1] == "AC":
        sl.append(sl[i - 1] + 1)
    else:
        sl.append(sl[i - 1])
for _ in range(q):
    l, r = list(map(int, input().split()))
    print((sl[r - 1] - sl[l - 1]))

-ll = list(list(map(int, input().split())) for _ in range(q)) -acl = [0] * n -cnt = 0 +sl = [0] -        cnt += 1 -    acl[i] = cnt -for i in range(q): -    l = ll[i][0] -    r = ll[i][1] -    print((acl[r - 1] - acl[l - 1])) +        sl.append(sl[i - 1] + 1) +    else: +        sl.append(sl[i - 1]) +for _ in range(q): +    l, r = list(map(int, input().split())) +    print((sl[r - 1] - sl[l - 1]))