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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	}
} 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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	}
} 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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	} 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[] data = new int[n]; data new int[n] n data[n-1] = 0 data[n-1] data n-1 n 1 0 for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		} int i = s.length()-2; int i = s.length()-2; i s.length()-2 s.length() s.length s 2 i >= 0 i 0 i-- i-- i {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		} {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		} data[i] = data[i+1] data[i] data i data[i+1] data i+1 i 1 if(s.substring(i, i+2).equals("AC"))
				data[i]++; 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" data[i]++ data[i] data i for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		} int i =0; int i =0; i 0 i < q i q i++ i++ i {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		} {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		} int l = sc.nextInt()-1; l sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int r = sc.nextInt()-1; r sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 System.out.println(data[l] - data[r]) System.out.println System.out System System.out data[l] - data[r] data[l] data l data[r] data r 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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	}
} 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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	}
} 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[] data = new int[n];
		data[n-1] = 0;
		for(int i = s.length()-2; i >= 0; i--) {
			data[i] = data[i+1];
			if(s.substring(i, i+2).equals("AC"))
				data[i]++;
		}
		for(int i =0; i < q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(data[l] - data[r]);
		}
	}
}