import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
} import java.util.*; util.* java public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    } main {
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int dmy = scan.nextInt(); dmy scan.nextInt() scan.nextInt scan final int query = scan.nextInt(); query scan.nextInt() scan.nextInt scan char[] input = scan.next().toCharArray(); input scan.next().toCharArray() scan.next().toCharArray scan.next() scan.next scan int[] counts = new int[100002]; counts new int[100002] 100002 int count = 0; count 0 for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        } int i = 1; int i = 1; i 1 i < input.length i input.length input input.length i++ i++ i {
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        } {
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        } if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            } input[i - 1] == 'A' && input[i] == 'C' input[i - 1] == 'A' input[i - 1] input i - 1 i 1 'A' input[i] == 'C' input[i] input i 'C' {
                count++;
            } count++ count counts[i] = count counts[i] counts i count int[] answer = new int[query]; answer new int[query] query for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        } int i = 0; int i = 0; i 0 i < query i query i++ i++ i {
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        } {
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        } int left = scan.nextInt(); left scan.nextInt() scan.nextInt scan int right = scan.nextInt(); right scan.nextInt() scan.nextInt scan answer[i] = counts[right-1] - counts[left-1] answer[i] answer i counts[right-1] - counts[left-1] counts[right-1] counts right-1 right 1 counts[left-1] counts left-1 left 1 for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        } int i = 0; int i = 0; i 0 i < query i query i++ i++ i {
            System.out.println(answer[i]);
        } {
            System.out.println(answer[i]);
        } System.out.println(answer[i]) System.out.println System.out System System.out answer[i] answer i String[] args args public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
} public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
} Main
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
}