import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc String s = sc.next(); s sc.next() sc.next sc int[] arr = new int[n+1]; arr new int[n+1] n+1 n 1 for (int i = 0; i < n-1; ++i) {
            if (s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i+1] = arr[i] + 1;
            else
                arr[i+1] = arr[i];
        } int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 ++i ++i i {
            if (s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i+1] = arr[i] + 1;
            else
                arr[i+1] = arr[i];
        } {
            if (s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i+1] = arr[i] + 1;
            else
                arr[i+1] = arr[i];
        } if (s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i+1] = arr[i] + 1;
            else
                arr[i+1] = arr[i]; 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' arr[i+1] = arr[i] + 1 arr[i+1] arr i+1 i 1 arr[i] + 1 arr[i] arr i 1 arr[i+1] = arr[i] arr[i+1] arr i+1 i 1 arr[i] arr i for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        } int i = 0; int i = 0; i 0 i < k i k ++i ++i i {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        } {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        } 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 System.out.println(arr[b] - arr[a]) System.out.println System.out System System.out arr[b] - arr[a] arr[b] arr b arr[a] arr a String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

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

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
}