import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int q = scan.nextInt(); q scan.nextInt() scan.nextInt scan String s = scan.next(); s scan.next() scan.next scan int[] sum = new int[n + 1]; sum new int[n + 1] n + 1 n 1 int i; i for(i = 1; i < n; i++) {
			if(s.substring(i - 1, i + 1).equals("AC")) {
				sum[i] = sum[i - 1] + 1;
			}else {
				sum[i] = sum[i - 1];
			}
		} i = 1; i = 1 i 1 i < n i n i++ i++ i {
			if(s.substring(i - 1, i + 1).equals("AC")) {
				sum[i] = sum[i - 1] + 1;
			}else {
				sum[i] = sum[i - 1];
			}
		} {
			if(s.substring(i - 1, i + 1).equals("AC")) {
				sum[i] = sum[i - 1] + 1;
			}else {
				sum[i] = sum[i - 1];
			}
		} if(s.substring(i - 1, i + 1).equals("AC")) {
				sum[i] = sum[i - 1] + 1;
			}else {
				sum[i] = sum[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" {
				sum[i] = sum[i - 1] + 1;
			} sum[i] = sum[i - 1] + 1 sum[i] sum i sum[i - 1] + 1 sum[i - 1] sum i - 1 i 1 1 {
				sum[i] = sum[i - 1];
			} sum[i] = sum[i - 1] sum[i] sum i sum[i - 1] sum i - 1 i 1 int start start end; end for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		} i = 0; i = 0 i 0 i < q i q i++ i++ i {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		} {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		} start = scan.nextInt() - 1 start scan.nextInt() - 1 scan.nextInt() scan.nextInt scan 1 end = scan.nextInt() - 1 end scan.nextInt() - 1 scan.nextInt() scan.nextInt scan 1 System.out.println(sum[end] - sum[start]) System.out.println System.out System System.out sum[end] - sum[start] sum[end] sum end sum[start] sum start String[] args args public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		String s = scan.next();
		int[] sum = new int[n + 1];

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

		int start,end;
		for(i = 0; i < q; i++) {
			start = scan.nextInt() - 1;
			end = scan.nextInt() - 1;

			System.out.println(sum[end] - sum[start]);
		}
	}
}
