import java.util.*;

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

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    } main {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int q = in.nextInt(); q in.nextInt() in.nextInt in String s = in.next(); s in.next() in.next in int[] indices = new int[n]; indices new int[n] n for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        } int i = 0; int i = 0; i 0 i < s.length() - 1 i s.length() - 1 s.length() s.length s 1 i++ i++ i {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        } {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        } if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            } s.charAt(i) == 'A' && s.charAt(i + 1) == 'C' s.charAt(i) == 'A' s.charAt(i) s.charAt s i 'A' s.charAt(i + 1) == 'C' s.charAt(i + 1) s.charAt s i + 1 i 1 'C' {
                indices[i] = 1;
            } indices[i] = 1 indices[i] indices i 1 int[] sums = new int[n + 1]; sums new int[n + 1] n + 1 n 1 for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            sums[i + 1] = sums[i] + indices[i];
        } {
            sums[i + 1] = sums[i] + indices[i];
        } sums[i + 1] = sums[i] + indices[i] sums[i + 1] sums i + 1 i 1 sums[i] + indices[i] sums[i] sums i indices[i] indices i for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        } {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        } int l = in.nextInt() - 1; l in.nextInt() - 1 in.nextInt() in.nextInt in 1 int r = in.nextInt() - 1; r in.nextInt() - 1 in.nextInt() in.nextInt in 1 int numAC = sums[r] - sums[l]; numAC sums[r] - sums[l] sums[r] sums r sums[l] sums l System.out.println(numAC) System.out.println System.out System System.out numAC String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

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

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

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

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