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

S = eval(input())

S_nums = [0 for _ in range(N+2)]

for idx in range(N):

  if S[idx-1:idx+1] == 'AC': S_nums[idx+1] = S_nums[idx] + 1

  else: S_nums[idx+1] = S_nums[idx]



for _ in range(Q):

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

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

S = '0' + eval(input())

acm_cntAC = [0 for _ in range(N+1)]

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

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

        acm_cntAC[i] = acm_cntAC[i-1] + 1

    else:

        acm_cntAC[i] = acm_cntAC[i - 1]



for _ in range(Q):

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

    if S[l-1:l+1] == 'AC':

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

    else:

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

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

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

-S = eval(input()) -S_nums = [0 for _ in range(N + 2)] -for idx in range(N): -    if S[idx - 1 : idx + 1] == "AC": -        S_nums[idx + 1] = S_nums[idx] + 1 +S = "0" + eval(input()) +acm_cntAC = [0 for _ in range(N + 1)] +for i in range(1, N + 1): +    if S[i - 1 : i + 1] == "AC": +        acm_cntAC[i] = acm_cntAC[i - 1] + 1 -        S_nums[idx + 1] = S_nums[idx] +        acm_cntAC[i] = acm_cntAC[i - 1] -    print((S_nums[r] - S_nums[l])) +    if S[l - 1 : l + 1] == "AC": +        print((acm_cntAC[r] - acm_cntAC[l - 1] - 1)) +    else: +        print((acm_cntAC[r] - acm_cntAC[l - 1]))