#!/usr/bin/env python3

import sys





def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):

    ans = []

    carray = [0] * N

    for i in range(1,N):

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

            carray[i] = carray[i-1]+1 

            # carray[i:] = map(lambda x:x+1, carray[i:])

        else:

            carray[i] = carray[i-1]

    # print(carray)

    for i in range(Q):

        # print(carray[l[i]-1:r[i]])

        t = carray[r[i]-1] - carray[l[i]-1]

        ans.append(t)



    for i in range(Q):

        print((ans[i]))

    return





# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    Q = int(next(tokens))  # type: int

    S = next(tokens)  # type: str

    l = [int()] * (Q)  # type: "List[int]" 

    r = [int()] * (Q)  # type: "List[int]" 

    for i in range(Q):

        l[i] = int(next(tokens))

        r[i] = int(next(tokens))

    solve(N, Q, S, l, r)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys





def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):

    ac = [0]*N

    for i in range(1,N):

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

            ac[i] = ac[i-1]+1

        else:

            ac[i] = ac[i-1]



    ans = [0]*Q

    for i in range(Q):

        ans[i] = ac[r[i]-1] - ac[l[i]-1]



    for i in ans:

        print(i)

    return





# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    Q = int(next(tokens))  # type: int

    S = next(tokens)  # type: str

    l = [int()] * (Q)  # type: "List[int]" 

    r = [int()] * (Q)  # type: "List[int]" 

    for i in range(Q):

        l[i] = int(next(tokens))

        r[i] = int(next(tokens))

    solve(N, Q, S, l, r)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    ans = []
    carray = [0] * N
    for i in range(1, N):
        if S[i - 1 : i + 1] == "AC":
            carray[i] = carray[i - 1] + 1
            # carray[i:] = map(lambda x:x+1, carray[i:])
        else:
            carray[i] = carray[i - 1]
    # print(carray)
    for i in range(Q):
        # print(carray[l[i]-1:r[i]])
        t = carray[r[i] - 1] - carray[l[i] - 1]
        ans.append(t)
    for i in range(Q):
        print((ans[i]))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    ac = [0] * N
    for i in range(1, N):
        if S[i - 1 : i + 1] == "AC":
            ac[i] = ac[i - 1] + 1
        else:
            ac[i] = ac[i - 1]
    ans = [0] * Q
    for i in range(Q):
        ans[i] = ac[r[i] - 1] - ac[l[i] - 1]
    for i in ans:
        print(i)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == "__main__":
    main()

-    ans = [] -    carray = [0] * N +    ac = [0] * N -            carray[i] = carray[i - 1] + 1 -            # carray[i:] = map(lambda x:x+1, carray[i:]) +            ac[i] = ac[i - 1] + 1 -            carray[i] = carray[i - 1] -    # print(carray) +            ac[i] = ac[i - 1] +    ans = [0] * Q -        # print(carray[l[i]-1:r[i]]) -        t = carray[r[i] - 1] - carray[l[i] - 1] -        ans.append(t) -    for i in range(Q): -        print((ans[i])) +        ans[i] = ac[r[i] - 1] - ac[l[i] - 1] +    for i in ans: +        print(i)