import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    }
} Main public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    } main {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc String s = sc.next(); s sc.next() sc.next sc int[] list = new int[n]; list new int[n] n int lastValue = 0; lastValue 0 for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        } {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        } if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            } s.substring(i - 1, i + 1).equals("AC") s.substring(i - 1, i + 1).equals s.substring(i - 1, i + 1) s.substring s i - 1 i 1 i + 1 i 1 "AC" {
                lastValue++;
            } lastValue++ lastValue list[i] = lastValue list[i] list i lastValue for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        } {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        } int l = sc.nextInt() - 1; l sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int r = sc.nextInt() - 1; r sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 System.out.println(list[r] - list[l]) System.out.println System.out System System.out list[r] - list[l] list[r] list r list[l] list l String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    }
} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] list = new int[n];
        int lastValue = 0;
        for (int i = 1; i < n; i++) {
            if (s.substring(i - 1, i + 1).equals("AC")) {
                lastValue++;
            }
            list[i] = lastValue;
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(list[r] - list[l]);
        }
    }
}