import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	}
} Main public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	} main {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int b=scan.nextInt(); b scan.nextInt() scan.nextInt scan String str=scan.next(); str scan.next() scan.next scan int C[]=new int[a]; C new int[a] a int s=0; s 0 for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		} int i=1; int i=1; i 1 i<a i a i++ i++ i {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		} {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		} char o=str.charAt(i-1); o str.charAt(i-1) str.charAt str i-1 i 1 char t=str.charAt(i); t str.charAt(i) str.charAt str i if(o=='A'&&t=='C') {
				s++;
			} o=='A'&&t=='C' o=='A' o 'A' t=='C' t 'C' {
				s++;
			} s++ s C[i]=s C[i] C i s for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		} int i=0; int i=0; i 0 i<b i b i++ i++ i {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		} {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		} int c=scan.nextInt(); c scan.nextInt() scan.nextInt scan int d=scan.nextInt(); d scan.nextInt() scan.nextInt scan System.out.println(C[d-1]-C[c-1]) System.out.println System.out System System.out C[d-1]-C[c-1] C[d-1] C d-1 d 1 C[c-1] C c-1 c 1 String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		String str=scan.next();
		int C[]=new int[a];
		int s=0;
		for(int i=1;i<a;i++) {
			char o=str.charAt(i-1);
			char t=str.charAt(i);
			if(o=='A'&&t=='C') {
				s++;
			}
			C[i]=s;
		}
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			int d=scan.nextInt();
			System.out.println(C[d-1]-C[c-1]);
		}
	}
}