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

#!/usr/bin/env python3



import sys



sys.setrecursionlimit(10**7)



input = sys.stdin.readline





def read_h(typ=int):

    return list(map(typ, input().split()))





def read_v(n, m=1, typ=int):

    return [read_h(typ) if m > 1 else typ(eval(input())) for _ in range(n)]





def main():

    n, q = read_h()

    s, = read_h(typ=str)

    rng = read_v(q, m=2)



    cnts = [0] * (n + 1)

    for i in range(len(s)):

        cnts[i + 1] = cnts[i] + (1 if s[i:i + 2] == 'AC' else 0)



    for l, r in rng:

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





if __name__ == '__main__':

    main()

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

#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(eval(input())) for _ in range(n)]


def main():
    n, q = read_h()
    (s,) = read_h(typ=str)
    rng = read_v(q, m=2)
    cnts = [0] * (n + 1)
    for i in range(len(s)):
        cnts[i + 1] = cnts[i] + (1 if s[i : i + 2] == "AC" else 0)
    for l, r in rng:
        print((cnts[r - 1] - cnts[l - 1]))


if __name__ == "__main__":
    main()

-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])) +#!/usr/bin/env python3 +import sys + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline + + +def read_h(typ=int): +    return list(map(typ, input().split())) + + +def read_v(n, m=1, typ=int): +    return [read_h(typ) if m > 1 else typ(eval(input())) for _ in range(n)] + + +def main(): +    n, q = read_h() +    (s,) = read_h(typ=str) +    rng = read_v(q, m=2) +    cnts = [0] * (n + 1) +    for i in range(len(s)): +        cnts[i + 1] = cnts[i] + (1 if s[i : i + 2] == "AC" else 0) +    for l, r in rng: +        print((cnts[r - 1] - cnts[l - 1])) + + +if __name__ == "__main__": +    main()