import java.util.*;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	}
} import java.util.*; util.* java public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	} 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[] count = new int[N]; count new int[N] N Arrays.fill(count,0) Arrays.fill Arrays count 0 for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		} int i = 1; int i = 1; i 1 i<N i N i++ i++ i {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		} {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		} if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			} S.charAt(i-1)=='A'&&S.charAt(i)=='C' S.charAt(i-1)=='A' S.charAt(i-1) S.charAt S i-1 i 1 'A' S.charAt(i)=='C' S.charAt(i) S.charAt S i 'C' {
				count[i] = count[i-1]+1;
			} count[i] = count[i-1]+1 count[i] count i count[i-1]+1 count[i-1] count i-1 i 1 1 {
				count[i] = count[i-1];
			} count[i] = count[i-1] count[i] count i count[i-1] count i-1 i 1 for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		} 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(count[r]-count[l]);
		} {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		} 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(count[r]-count[l]) System.out.println System.out System System.out count[r]-count[l] count[r] count r count[l] count l String[] args args public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	}
} public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	}
} Main
import java.util.*;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N];
		Arrays.fill(count,0);
		for(int i = 1;i<N;i++) {
			if(S.charAt(i-1)=='A'&&S.charAt(i)=='C') {
				count[i] = count[i-1]+1;
			}else {
				count[i] = count[i-1];
			}
		}
		
		for(int i =0;i<Q;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			System.out.println(count[r]-count[l]);
		}
	}
}