import java.util.Scanner;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
} import java.util.Scanner; Scanner java.util class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
} Solver Scanner sc; sc public void Solve() {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    } Solve {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    } 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 ruisekiwa[] = new int[n + 1]; ruisekiwa new int[n + 1] n + 1 n 1 for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        } int i = 0; int i = 0; i 0 i < ruisekiwa.length - 2 i ruisekiwa.length - 2 ruisekiwa.length ruisekiwa ruisekiwa.length 2 i++ i++ i {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        } {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        } String sub = s.substring(i, i + 2); sub s.substring(i, i + 2) s.substring s i i + 2 i 2 if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            } sub.equals("AC") sub.equals sub "AC" {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1 ruisekiwa[i + 2] ruisekiwa i + 2 i 2 ruisekiwa[i + 1] + 1 ruisekiwa[i + 1] ruisekiwa i + 1 i 1 1 {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            } ruisekiwa[i + 2] = ruisekiwa[i + 1] ruisekiwa[i + 2] ruisekiwa i + 2 i 2 ruisekiwa[i + 1] ruisekiwa i + 1 i 1 for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        } {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        } int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc System.out.println(ruisekiwa[r] - ruisekiwa[l]) System.out.println System.out System System.out ruisekiwa[r] - ruisekiwa[l] ruisekiwa[r] ruisekiwa r ruisekiwa[l] ruisekiwa l Solver(Scanner in) {
        this.sc = in;
    } Solver {
        this.sc = in;
    } this.sc = in this.sc this this.sc in Scanner in in public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Solver s = new Solver(sc); s new Solver(sc) s.Solve() s.Solve s sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
} Main
import java.util.Scanner;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int ruisekiwa[] = new int[n + 1];
        for (int i = 0; i < ruisekiwa.length - 2; i++) {
            String sub = s.substring(i, i + 2);
            if (sub.equals("AC")) {
                ruisekiwa[i + 2] = ruisekiwa[i + 1] + 1;
            } else {
                ruisekiwa[i + 2] = ruisekiwa[i + 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(ruisekiwa[r] - ruisekiwa[l]);
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}
