import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	}
} Main public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	} main {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	} try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int Q = Integer.parseInt(sc.next()); Q Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String S = sc.next(); S sc.next() sc.next sc int[][] lr = new int[Q][2]; lr new int[Q][2] Q 2 for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			} int i = 0; int i = 0; i 0 i < Q i Q i ++ i ++ i {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			} {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			} lr[i][0] = Integer.parseInt(sc.next()) lr[i][0] lr[i] lr i 0 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc lr[i][1] = Integer.parseInt(sc.next()) lr[i][1] lr[i] lr i 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc final String AC = "AC"; AC "AC" int[][] counter = new int[S.length()][2]; counter new int[S.length()][2] S.length() S.length S 2 int count = 0; count 0 for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			} 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 {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			} {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			} counter[i][1] = count counter[i][1] counter[i] counter i 1 count if(AC.equals(S.substring(i, i +2))) {
					count++;
				} AC.equals(S.substring(i, i +2)) AC.equals AC S.substring(i, i +2) S.substring S i i +2 i 2 {
					count++;
				} count++ count counter[S.length()-1][1] = count counter[S.length()-1][1] counter[S.length()-1] counter S.length()-1 S.length() S.length S 1 1 count for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			} int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			} {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			} System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]) System.out.println System.out System System.out counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1] counter[lr[i][1] -1][1] counter[lr[i][1] -1] counter lr[i][1] -1 lr[i][1] lr[i] lr i 1 1 1 counter[lr[i][0] -1][1] counter[lr[i][0] -1] counter lr[i][0] -1 lr[i][0] lr[i] lr i 0 1 1 String[] args args public class Main {
	
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	}
} public class Main {
	
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	}
} Main
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			int Q = Integer.parseInt(sc.next());
			String S = sc.next();
			int[][] lr = new int[Q][2];
			for(int i = 0; i < Q; i ++) {
				lr[i][0] = Integer.parseInt(sc.next());
				lr[i][1] = Integer.parseInt(sc.next());
			}
			final String AC = "AC";
			int[][] counter = new int[S.length()][2];
			int count = 0;
			for(int i = 0; i < S.length()-1; i++) {
				counter[i][1] = count;
				if(AC.equals(S.substring(i, i +2))) {
					count++;
				}
			}
			
			counter[S.length()-1][1] = count;
			for(int i = 0; i < Q; i++) {
				System.out.println(counter[lr[i][1] -1][1] - counter[lr[i][0] -1][1]);
			}
		} // Scanner Close
	}
}