import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} Main static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	} exec {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	} in.nextInt() in.nextInt in int Q = in.nextInt(); Q in.nextInt() in.nextInt in String S = in.next(); S in.next() in.next in int[] t = new int[S.length()]; t new int[S.length()] S.length() S.length S for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		} int i = 0; int i = 0; i 0 i < t.length - 1 i t.length - 1 t.length t t.length 1 i += 1 i += 1 i 1 {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		} {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		} if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[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' {
				t[i + 1] = t[i] + 1;
			} t[i + 1] = t[i] + 1 t[i + 1] t i + 1 i 1 t[i] + 1 t[i] t i 1 {
				t[i + 1] = t[i];
			} t[i + 1] = t[i] t[i + 1] t i + 1 i 1 t[i] t i for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		} int i = 0; int i = 0; i 0 i < Q i Q i += 1 i += 1 i 1 {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		} {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		} int l = in.nextInt(); l in.nextInt() in.nextInt in int r = in.nextInt(); r in.nextInt() in.nextInt in out.println(t[r - 1] - t[l - 1]) out.println out t[r - 1] - t[l - 1] t[r - 1] t r - 1 r 1 t[l - 1] t l - 1 l 1 Scanner in in PrintStream out out public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	} main {
		exec(new Scanner(System.in), System.out);
	} exec(new Scanner(System.in), System.out) exec new Scanner(System.in) System.out System System.out String[] args args public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} Main
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}
