import 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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		sc.close();
	}
} import java.util.*; util.* java 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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();

		int[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		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[] t = new int[n + 1]; t new int[n + 1] n + 1 n 1 for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		} {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		} t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0) t[i + 1] t i + 1 i 1 t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0) t[i] t i (s.substring(i, i + 2).equals("AC") ? 1 : 0) s.substring(i, i + 2).equals("AC") s.substring(i, i + 2).equals s.substring(i, i + 2) s.substring s i i + 2 i 2 "AC" 1 0 for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		} {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		} int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc l-- l r-- r int ans = t[r] - t[l]; ans t[r] - t[l] t[r] t r t[l] t l System.out.println(ans) System.out.println System.out System System.out ans 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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		sc.close();
	}
} Main
import 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[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			// 2文字切り出して"AC"なら+1
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}

		sc.close();
	}
}
