import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int Q = Integer.parseInt(scanner.next()); Q Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner String S = scanner.next(); S scanner.next() scanner.next scanner int[] ac = new int[N]; ac new int[N] N Arrays.fill(ac, 0) Arrays.fill Arrays ac 0 for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        } 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') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        } {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        } if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[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' {
                ac[i+1] = ac[i] + 1;
            } ac[i+1] = ac[i] + 1 ac[i+1] ac i+1 i 1 ac[i] + 1 ac[i] ac i 1 {
                ac[i+1] = ac[i];
            } ac[i+1] = ac[i] ac[i+1] ac i+1 i 1 ac[i] ac i for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        } {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        } Integer l = Integer.parseInt(scanner.next()) l Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner r = Integer.parseInt(scanner.next()); r Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int count = 0; count 0 count = ac[r-1] - ac[l-1] count ac[r-1] - ac[l-1] ac[r-1] ac r-1 r 1 ac[l-1] ac l-1 l 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String S = scanner.next();
 
        int[] ac = new int[N];
        Arrays.fill(ac, 0);
 
        for (int i = 0; i < S.length()-1; i++) {
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                ac[i+1] = ac[i] + 1;
            } else {
                ac[i+1] = ac[i];
            }
        }
        for (int i = 0; i < Q; i++) {
            Integer l = Integer.parseInt(scanner.next()), r = Integer.parseInt(scanner.next());
            int count = 0;
            // if(S.length() < l) continue;
            // if(S.length() < r)  r = S.length();
            count = ac[r-1] - ac[l-1];
            System.out.println(count);
        }
 
    }
}