import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[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 char[] acgt = sc.next().toCharArray(); acgt sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int[] cArray = new int[n]; cArray new int[n] n int count = 0; count 0 for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		} {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		} if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			} acgt[i] == 'A' && acgt[i + 1] == 'C' acgt[i] == 'A' acgt[i] acgt i 'A' acgt[i + 1] == 'C' acgt[i + 1] acgt i + 1 i 1 'C' {
				count++;
			} count++ count cArray[i + 1] = count cArray[i + 1] cArray i + 1 i 1 count for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		} int j = 0; int j = 0; j 0 j < q j q j++ j++ j {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		} {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		} int l = sc.nextInt() - 1; l sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int r = sc.nextInt() - 1; r sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 System.out.println(cArray[r] - cArray[l]) System.out.println System.out System System.out cArray[r] - cArray[l] cArray[r] cArray r cArray[l] cArray l sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(cArray[r] - cArray[l]);
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

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