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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[L-1]);
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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[] cnt = new int[N+1]; cnt new int[N+1] N+1 N 1 for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[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 {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		} {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		} cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0) cnt[i+1] cnt i+1 i 1 cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0) cnt[i] cnt 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 String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1)); SLastSub String.valueOf(S.charAt(N-2)+S.charAt(N-1)) String.valueOf String S.charAt(N-2)+S.charAt(N-1) S.charAt(N-2) S.charAt S N-2 N 2 S.charAt(N-1) S.charAt S N-1 N 1 cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0) cnt[N] cnt N cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0) cnt[N-1] cnt N-1 N 1 (SLastSub.equals("AC") ? 1 : 0) SLastSub.equals("AC") SLastSub.equals SLastSub "AC" 1 0 for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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(cnt[R-1]-cnt[L-1]);
		} {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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(cnt[R-1]-cnt[L-1]) System.out.println System.out System System.out cnt[R-1]-cnt[L-1] cnt[R-1] cnt R-1 R 1 cnt[L-1] cnt 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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[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[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[L-1]);
		}
		sc.close();
	}
}