n, k = list(map(int, input().split(' ')))

orig_a = eval(input())

acs = {}

for i in range(n):

  if i < 1:

    acs[i] = 0

  else:

    acs[i] = acs[i-1] + (orig_a[i-1: i+1] == 'AC')

for _ in range(k):

  s, e = list(map(int, input().split(' ')))

  print((acs[e-1] - acs[s-1]))

n, k = list(map(int, input().split(' ')))

a = eval(input())

acs = [0] * n

for i in range(1, n):

  acs[i] = acs[i-1] + (a[i-1: i+1] == 'AC')

print(('\n'.join(map(str, [acs[e-1] - acs[s-1] for s, e in [list(map(int, input().split(' '))) for _ in range(k)]]))))
n, k = list(map(int, input().split(" ")))
orig_a = eval(input())
acs = {}
for i in range(n):
    if i < 1:
        acs[i] = 0
    else:
        acs[i] = acs[i - 1] + (orig_a[i - 1 : i + 1] == "AC")
for _ in range(k):
    s, e = list(map(int, input().split(" ")))
    print((acs[e - 1] - acs[s - 1]))

n, k = list(map(int, input().split(" ")))
a = eval(input())
acs = [0] * n
for i in range(1, n):
    acs[i] = acs[i - 1] + (a[i - 1 : i + 1] == "AC")
print(
    (
        "\n".join(
            map(
                str,
                [
                    acs[e - 1] - acs[s - 1]
                    for s, e in [list(map(int, input().split(" "))) for _ in range(k)]
                ],
            )
        )
    )
)

-orig_a = eval(input()) -acs = {} -for i in range(n): -    if i < 1: -        acs[i] = 0 -    else: -        acs[i] = acs[i - 1] + (orig_a[i - 1 : i + 1] == "AC") -for _ in range(k): -    s, e = list(map(int, input().split(" "))) -    print((acs[e - 1] - acs[s - 1])) +a = eval(input()) +acs = [0] * n +for i in range(1, n): +    acs[i] = acs[i - 1] + (a[i - 1 : i + 1] == "AC") +print( +    ( +        "\n".join( +            map( +                str, +                [ +                    acs[e - 1] - acs[s - 1] +                    for s, e in [list(map(int, input().split(" "))) for _ in range(k)] +                ], +            ) +        ) +    ) +)