import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    }

    private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    }

    private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    }
} Main private static java.util.Scanner scanner = new java.util.Scanner(System.in); scanner new java.util.Scanner(System.in) public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    } main {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    } int n = scanner.nextInt() n scanner.nextInt() scanner.nextInt scanner q = scanner.nextInt(); q scanner.nextInt() scanner.nextInt scanner String s = scanner.next(); s scanner.next() scanner.next scanner List<Integer> ac = new ArrayList<>(); ac new ArrayList<>() for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i); int i = 1; int i = 1; i 1 i < n i n i++ i++ i if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i); if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(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' ac.add(i) ac.add ac i for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        } {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        } int l = scanner.nextInt() l scanner.nextInt() scanner.nextInt scanner r = scanner.nextInt(); r scanner.nextInt() scanner.nextInt scanner int l1 = search(ac, l); l1 search(ac, l) search ac l int r1 = search(ac, r); r1 search(ac, r) search ac r System.out.println(r1 - l1) System.out.println System.out System System.out r1 - l1 r1 l1 String[] args args private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    } search {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    } int r = Collections.binarySearch(list, key); r Collections.binarySearch(list, key) Collections.binarySearch Collections list key return r < 0 ? ~r : r; r < 0 ? ~r : r r < 0 r 0 ~r r r List<Integer> list list int key key public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    }

    private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    }
} public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    }

    private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = search(ac, l);
            int r1 = search(ac, r);
            System.out.println(r1 - l1);
        }
    }

    private static int search(List<Integer> list, int key) {
        int r = Collections.binarySearch(list, key);
        return r < 0 ? ~r : r;
    }
}