
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	}
} import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	}
} Main private static Scanner sc; sc public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	} main {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	} sc = new Scanner(System.in) sc new Scanner(System.in) sc.nextInt() sc.nextInt sc int Q = sc.nextInt(); Q sc.nextInt() sc.nextInt sc String[] S = sc.next().split(""); S sc.next().split("") sc.next().split sc.next() sc.next sc "" int[][] questions = new int[Q][2]; questions new int[Q][2] Q 2 for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		} int i = 0; int i = 0; i 0 i < questions.length i questions.length questions questions.length i++ i++ i {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		} {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		} questions[i][0] = sc.nextInt() questions[i][0] questions[i] questions i 0 sc.nextInt() sc.nextInt sc questions[i][1] = sc.nextInt() questions[i][1] questions[i] questions i 1 sc.nextInt() sc.nextInt sc int[] arry = new int[S.length]; arry new int[S.length] S.length S S.length for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		} int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		} {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		} if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			} i == 0 i 0 {
				arry[i] = 0;
			} arry[i] = 0 arry[i] arry i 0 {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			} if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				} "AC".equals(S[i - 1] + S[i]) "AC".equals "AC" S[i - 1] + S[i] S[i - 1] S i - 1 i 1 S[i] S i {
					arry[i] = arry[i - 1] + 1;
				} arry[i] = arry[i - 1] + 1 arry[i] arry i arry[i - 1] + 1 arry[i - 1] arry i - 1 i 1 1 {
					arry[i] = arry[i - 1];
				} arry[i] = arry[i - 1] arry[i] arry i arry[i - 1] arry i - 1 i 1 for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		} int i = 0; int i = 0; i 0 i < questions.length i questions.length questions questions.length i++ i++ i {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		} {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		} System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]) System.out.println System.out System System.out arry[questions[i][1] - 1] - arry[questions[i][0] - 1] arry[questions[i][1] - 1] arry questions[i][1] - 1 questions[i][1] questions[i] questions i 1 1 arry[questions[i][0] - 1] arry questions[i][0] - 1 questions[i][0] questions[i] questions i 0 1 String[] args args public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	}
} public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	}
} Main

import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		sc.nextInt();
		int Q = sc.nextInt();

		String[] S = sc.next().split("");

		int[][] questions = new int[Q][2];

		for (int i = 0; i < questions.length; i++) {
			questions[i][0] = sc.nextInt();
			questions[i][1] = sc.nextInt();

		}

		// N字ごとのACの表れる回数を数えて配列に格納しておく

		int[] arry = new int[S.length];

		for (int i = 0; i < S.length; i++) {
			if (i == 0) {
				arry[i] = 0;
			} else {
				if ("AC".equals(S[i - 1] + S[i])) {
					arry[i] = arry[i - 1] + 1;
				} else {
					arry[i] = arry[i - 1];
				}
			}
		}

		for (int i = 0; i < questions.length; i++) {
			System.out.println(arry[questions[i][1] - 1] - arry[questions[i][0] - 1]);
		}

	}
}