import sys



n, q = list(map(int, sys.stdin.readline().split()))

s = sys.stdin.readline()



mlist = [0] * q

for i in range(q):

    mlist[i] = list([int(i) for i in sys.stdin.readline().split()])



elist = [0] * (n+1)



for i in range(n - 1):

    tmp = s[i:i+2]

    if 'AC' in tmp:

        elist[i + 2] = elist[i+1] + 1

    else:

        elist[i + 2] = elist[i+1]



for i in range(q):

    l, r = mlist[i]

    print((elist[r] - elist[l]))

import sys



n, q = list(map(int, sys.stdin.readline().split()))

s = sys.stdin.readline()



elist = [0] * (n+1)

for i in range(n - 1):

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



for i in range(q):

    l, r = list(map(int, sys.stdin.readline().split()))

    print((elist[r] - elist[l]))

import sys

n, q = list(map(int, sys.stdin.readline().split()))
s = sys.stdin.readline()
mlist = [0] * q
for i in range(q):
    mlist[i] = list([int(i) for i in sys.stdin.readline().split()])
elist = [0] * (n + 1)
for i in range(n - 1):
    tmp = s[i : i + 2]
    if "AC" in tmp:
        elist[i + 2] = elist[i + 1] + 1
    else:
        elist[i + 2] = elist[i + 1]
for i in range(q):
    l, r = mlist[i]
    print((elist[r] - elist[l]))

import sys

n, q = list(map(int, sys.stdin.readline().split()))
s = sys.stdin.readline()
elist = [0] * (n + 1)
for i in range(n - 1):
    elist[i + 2] = elist[i + 1] + (1 if "AC" == s[i : i + 2] else 0)
for i in range(q):
    l, r = list(map(int, sys.stdin.readline().split()))
    print((elist[r] - elist[l]))

-mlist = [0] * q -for i in range(q): -    mlist[i] = list([int(i) for i in sys.stdin.readline().split()]) -    tmp = s[i : i + 2] -    if "AC" in tmp: -        elist[i + 2] = elist[i + 1] + 1 -    else: -        elist[i + 2] = elist[i + 1] +    elist[i + 2] = elist[i + 1] + (1 if "AC" == s[i : i + 2] else 0) -    l, r = mlist[i] +    l, r = list(map(int, sys.stdin.readline().split()))