import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
} Main public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	} main {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int q = in.nextInt(); q in.nextInt() in.nextInt in String s = in.next(); s in.next() in.next in int[] t = new int[n+1]; t new int[n+1] n+1 n 1 for(int k =0; k<n+1; k++) {
			t[k]=0;
		} int k =0; int k =0; k 0 k<n+1 k n+1 n 1 k++ k++ k {
			t[k]=0;
		} {
			t[k]=0;
		} t[k]=0 t[k] t k 0 for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		} int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		} {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		} String sub = s.substring(i,i+2); sub s.substring(i,i+2) s.substring s i i+2 i 2 t[i+1] = t[i] + (sub.equals("AC")? 1:0) t[i+1] t i+1 i 1 t[i] + (sub.equals("AC")? 1:0) t[i] t i (sub.equals("AC")? 1:0) sub.equals("AC") sub.equals sub "AC" 1 0 for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		} int j=0; int j=0; j 0 j<q j q j++ j++ j {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		} {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		} int l= in.nextInt(); l in.nextInt() in.nextInt in int r= in.nextInt(); r in.nextInt() in.nextInt in System.out.println(t[r-1]-t[l-1]) System.out.println System.out System System.out t[r-1]-t[l-1] t[r-1] t r-1 r 1 t[l-1] t l-1 l 1 String[] args args public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
} public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
}
