import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

} Main public static void main(String[] args) {
		Main main = new Main();
		main.run();
	} main {
		Main main = new Main();
		main.run();
	} Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		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]; cnt new int[n] n for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		} {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		} if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			} s.substring(i-1, i+1).equals("AC") s.substring(i-1, i+1).equals s.substring(i-1, i+1) s.substring s i-1 i 1 i+1 i 1 "AC" {
				cnt[i]=cnt[i-1]+1;
			} cnt[i]=cnt[i-1]+1 cnt[i] cnt i cnt[i-1]+1 cnt[i-1] cnt i-1 i 1 1 {
				cnt[i]=cnt[i-1];
			} cnt[i]=cnt[i-1] cnt[i] cnt i cnt[i-1] cnt i-1 i 1 for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		} int i=0; int i=0; i 0 i<q i q i++ i++ i {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		} {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		} int l=sc.nextInt(); l sc.nextInt() sc.nextInt sc l-- l int r=sc.nextInt(); r sc.nextInt() sc.nextInt sc r-- r System.out.println(cnt[r]-cnt[l]) System.out.println System.out System System.out cnt[r]-cnt[l] cnt[r] cnt r cnt[l] cnt l sc.close() sc.close sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

} public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

}
