import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    }
} import java.io.BufferedInputStream; BufferedInputStream java.io import java.io.BufferedOutputStream; BufferedOutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    }
} Main private static long n; n // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    } main {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    } try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        } {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        } BufferedInputStream in = new BufferedInputStream(System.in) BufferedInputStream in = new BufferedInputStream(System.in) new BufferedInputStream(System.in) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) new PrintWriter(new BufferedOutputStream(System.out)) Scanner sc = new Scanner(in); sc new Scanner(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[] cnts = new int[s.length()]; cnts new int[s.length()] s.length() s.length s for (int i = 1; i < s.length(); i++) {
                cnts[i] = cnts[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') cnts[i]++;
            } int i = 1; int i = 1; i 1 i < s.length() i s.length() s.length s i++ i++ i {
                cnts[i] = cnts[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') cnts[i]++;
            } {
                cnts[i] = cnts[i - 1];
                if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') cnts[i]++;
            } cnts[i] = cnts[i - 1] cnts[i] cnts i cnts[i - 1] cnts i - 1 i 1 if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') cnts[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' cnts[i]++ cnts[i] cnts i for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            } {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            } int a = sc.nextInt() - 1; a sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int b = sc.nextInt() - 1; b sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]); ret cnts[b] - (a == 0 ? 0 : cnts[a - 1]) cnts[b] cnts b (a == 0 ? 0 : cnts[a - 1]) a == 0 a 0 0 cnts[a - 1] cnts a - 1 a 1 if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--; a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C' a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C' a > 0 a 0 s.charAt(a - 1) == 'A' s.charAt(a - 1) s.charAt s a - 1 a 1 'A' s.charAt(a) == 'C' s.charAt(a) s.charAt s a 'C' ret-- ret out.println(ret) out.println out ret String[] args args public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    }
} public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    }
} Main
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.next();

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

            for (int i = 0; i < q; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                int ret = cnts[b] - (a == 0 ? 0 : cnts[a - 1]);
                if (a > 0 && s.charAt(a - 1) == 'A' && s.charAt(a) == 'C') ret--;

                out.println(ret);
            }
        }
    }
}
