import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    }
} Main public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    } main {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    } try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        } {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        } Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int q = scanner.nextInt(); q scanner.nextInt() scanner.nextInt scanner String s = scanner.next(); s scanner.next() scanner.next scanner int[] sum = new int[s.length()]; sum new int[s.length()] s.length() s.length s for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            } int i = 1; int i = 1; i 1 i < s.length() i s.length() s.length s i++ i++ i {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            } {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            } sum[i] = sum[i - 1] sum[i] sum i sum[i - 1] sum i - 1 i 1 if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                } s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C' s.charAt(i - 1) == 'A' s.charAt(i - 1) s.charAt s i - 1 i 1 'A' s.charAt(i ) == 'C' s.charAt(i ) s.charAt s i 'C' {
                    sum[i]++;
                } sum[i]++ sum[i] sum i for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            } {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            } int L = scanner.nextInt(); L scanner.nextInt() scanner.nextInt scanner int R = scanner.nextInt(); R scanner.nextInt() scanner.nextInt scanner System.out.println(sum[R - 1] - sum[L - 1]) System.out.println System.out System System.out sum[R - 1] - sum[L - 1] sum[R - 1] sum R - 1 R 1 sum[L - 1] sum L - 1 L 1 String[] args args public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int q = scanner.nextInt();
            String s = scanner.next();

            int[] sum = new int[s.length()];
            for(int i = 1; i < s.length(); i++) {
                sum[i] = sum[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i ) == 'C') {
                    sum[i]++;
                }
            }
            for (int i = 0; i < q; i++) {
                int L = scanner.nextInt();
                int R = scanner.nextInt();
                // ACACTACG
                // 01234567
                // 01122233
                System.out.println(sum[R - 1] - sum[L - 1]);
            }
        }
    }
}
