import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    }

} import java.util.*; util.* java public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    }

} Main public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    } main {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N    = scan.nextInt(); N scan.nextInt() scan.nextInt scan int Q    = scan.nextInt(); Q scan.nextInt() scan.nextInt scan String S = scan.next(); S scan.next() scan.next scan int[] acCount = new int[N]; acCount new int[N] N String subStr; subStr for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        } {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        } if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            } i == 0 i 0 {

              acCount[i] = 0;

            } acCount[i] = 0 acCount[i] acCount i 0 {

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            } subStr =S.substring(i-1,i+1) subStr S.substring(i-1,i+1) S.substring S i-1 i 1 i+1 i 1 if(subStr.equals("AC")){

                    acCount[i] = 1;
                } subStr.equals("AC") subStr.equals subStr "AC" {

                    acCount[i] = 1;
                } acCount[i] = 1 acCount[i] acCount i 1 acCount[i] = acCount[i-1] + acCount[i] acCount[i] acCount i acCount[i-1] + acCount[i] acCount[i-1] acCount i-1 i 1 acCount[i] acCount i int[] ans = new int[Q]; ans new int[Q] Q for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        } {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        } int l    = scan.nextInt(); l scan.nextInt() scan.nextInt scan int r    = scan.nextInt(); r scan.nextInt() scan.nextInt scan ans[i] = acCount[r-1] - acCount[l-1] ans[i] ans i acCount[r-1] - acCount[l-1] acCount[r-1] acCount r-1 r 1 acCount[l-1] acCount l-1 l 1 for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {

            System.out.println(ans[i]);
        } {

            System.out.println(ans[i]);
        } System.out.println(ans[i]) System.out.println System.out System System.out ans[i] ans i String[] args args public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    }

} public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    }

} Main
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N    = scan.nextInt();
        int Q    = scan.nextInt();
        String S = scan.next();

        int[] acCount = new int[N];
        String subStr;


        for(int i = 0; i < N; i++) {

            if(i == 0){

              acCount[i] = 0;

            }else{

                subStr =S.substring(i-1,i+1);
                //System.out.println(subStr);

                if(subStr.equals("AC")){

                    acCount[i] = 1;
                }

                acCount[i] = acCount[i-1] + acCount[i];
            }

            //System.out.println(i+1 + "文字目まで:" + acCount[i]);
        }



        int[] ans = new int[Q];
        for(int i = 0; i < Q; i++) {

            int l    = scan.nextInt();
            int r    = scan.nextInt();

            ans[i] = acCount[r-1] - acCount[l-1];
        }



        for(int i = 0; i < Q; i++) {

            System.out.println(ans[i]);
        }



    }

}