import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

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

        sc.close();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

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

        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

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

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

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

        sc.close();
    } 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 acnum[] = new int[n]; acnum new int[n] n Arrays.fill(acnum, 0) Arrays.fill Arrays acnum 0 for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        } {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        } String tmp = s.substring(i, i + 2); tmp s.substring(i, i + 2) s.substring s i i + 2 i 2 if (tmp.equals("AC")) {
                acnum[i]++;
            } tmp.equals("AC") tmp.equals tmp "AC" {
                acnum[i]++;
            } acnum[i]++ acnum[i] acnum i for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            acnum[i + 1] += acnum[i];
        } {
            acnum[i + 1] += acnum[i];
        } acnum[i + 1] += acnum[i] acnum[i + 1] acnum i + 1 i 1 acnum[i] acnum i for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = 0;
            if (l == 1) {
                ans = acnum[r - 2];
            } else {
                ans = acnum[r - 2] - acnum[l - 2];
            }
            System.out.println(ans);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = 0;
            if (l == 1) {
                ans = acnum[r - 2];
            } else {
                ans = acnum[r - 2] - acnum[l - 2];
            }
            System.out.println(ans);
        } {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = 0;
            if (l == 1) {
                ans = acnum[r - 2];
            } else {
                ans = acnum[r - 2] - acnum[l - 2];
            }
            System.out.println(ans);
        } int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int ans = 0; ans 0 if (l == 1) {
                ans = acnum[r - 2];
            } else {
                ans = acnum[r - 2] - acnum[l - 2];
            } l == 1 l 1 {
                ans = acnum[r - 2];
            } ans = acnum[r - 2] ans acnum[r - 2] acnum r - 2 r 2 {
                ans = acnum[r - 2] - acnum[l - 2];
            } ans = acnum[r - 2] - acnum[l - 2] ans acnum[r - 2] - acnum[l - 2] acnum[r - 2] acnum r - 2 r 2 acnum[l - 2] acnum l - 2 l 2 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

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

        sc.close();
    }
}
