import java.util.Scanner;

public class Main {

	public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	}
} Main public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	} seach_AC {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	} int result = 0; result 0 for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			} int i = start; int i = start; i start i < end i end i++ i++ i {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			} {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			} if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				} 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" {
					i++;
					result++;
				} i++ i result++ result return result; result String s s int start start int end end public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	} main {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-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[] table = new int[s.length()]; table new int[s.length()] s.length() s.length s table[0] = 0 table[0] table 0 0 for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		} int i = 1; int i = 1; i 1 i < s.length() i s.length() s.length s i++ i++ i {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		} {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		} table[i] = table[i-1] + seach_AC(s,i-1,i) table[i] table i table[i-1] + seach_AC(s,i-1,i) table[i-1] table i-1 i 1 seach_AC(s,i-1,i) seach_AC s i-1 i 1 i System.out.println("") System.out.println System.out System System.out "" for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		} {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		} int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc System.out.println(table[l-1] - table[r-1]) System.out.println System.out System System.out table[l-1] - table[r-1] table[l-1] table l-1 l 1 table[r-1] table r-1 r 1 sc.close() sc.close sc String[] args args public class Main {

	public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	}
} public class Main {

	public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static int seach_AC (String s,int start,int end) {
		int result = 0;
			for(int i = start; i < end; i++) {
				if(s.substring(i,i+2).equals("AC")) {
					i++;
					result++;
				}
			}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] table = new int[s.length()];
		table[0] = 0;
		for(int i = 1; i < s.length(); i++) {
			table[i] = table[i-1] + seach_AC(s,i-1,i); 
		}
		
		System.out.println("");
		for(int i = 0; i < q; i++) {
			int r = sc.nextInt();
			int l = sc.nextInt();
			System.out.println(table[l-1] - table[r-1]);
		}
		sc.close();
	}
}
