import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc String s = sc.next(); s sc.next() sc.next sc int sum[] = new int[n]; sum new int[n] n for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		} {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		} if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			} "AC".equals(s.substring(i - 1, i + 1)) "AC".equals "AC" s.substring(i - 1, i + 1) s.substring s i - 1 i 1 i + 1 i 1 {
				sum[i] = sum[i - 1] + 1;
			} sum[i] = sum[i - 1] + 1 sum[i] sum i sum[i - 1] + 1 sum[i - 1] sum i - 1 i 1 1 {
				sum[i] = sum[i - 1];
			} sum[i] = sum[i - 1] sum[i] sum i sum[i - 1] sum i - 1 i 1 for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		} {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		} int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc System.out.println(sum[r - 1] - sum[l - 1]) System.out.println System.out System System.out sum[r - 1] - sum[l - 1] sum[r - 1] sum r - 1 r 1 sum[l - 1] sum l - 1 l 1 sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int sum[] = new int[n];

		for (int i = 1; i < n; i++) {
			if ("AC".equals(s.substring(i - 1, i + 1))) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r - 1] - sum[l - 1]);
		}

		sc.close();

	}

}
