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

S = list(eval(input()))



mark = [0]*(N+1)



for i in range(2, N+1):

    if S[i-2] == 'A' and S[i-1] == 'C':

        mark[i] = mark[i-1] + 1

    else:

        mark[i] = mark[i-1]



for i in range(Q):

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

    l = l - 1

    r = r - 1

    print((mark[r+1]-mark[l+1]))
N, Q = list(map(int, input().split()))

S = list(eval(input()))

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



mark = [0]*(N+1)



for i in range(2, N+1):

    if S[i-2] == 'A' and S[i-1] == 'C':

        mark[i] = mark[i-1] + 1

    else:

        mark[i] = mark[i-1]



for i in lr:

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

N, Q = list(map(int, input().split()))
S = list(eval(input()))
lr = [list(map(int, input().split())) for i in range(Q)]
mark = [0] * (N + 1)
for i in range(2, N + 1):
    if S[i - 2] == "A" and S[i - 1] == "C":
        mark[i] = mark[i - 1] + 1
    else:
        mark[i] = mark[i - 1]
for i in lr:
    print((mark[i[1]] - mark[i[0]]))

+lr = [list(map(int, input().split())) for i in range(Q)] -for i in range(Q): -    l, r = list(map(int, input().split())) -    l = l - 1 -    r = r - 1 -    print((mark[r + 1] - mark[l + 1])) +for i in lr: +    print((mark[i[1]] - mark[i[0]]))