import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
} Main public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		} {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		} Scanner sc = new Scanner(br) Scanner sc = new Scanner(br) new Scanner(br) int len = sc.nextInt(); len sc.nextInt() sc.nextInt sc int numOfQuestion = sc.nextInt(); numOfQuestion sc.nextInt() sc.nextInt sc String str = sc.next(); str sc.next() sc.next sc question(str, numOfQuestion, sc) question str numOfQuestion sc String[] args args private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	} question {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	} int[] counts = countAC(str); counts countAC(str) countAC str for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		} int i = 1; int i = 1; i 1 i <= numOfQuestion i numOfQuestion i++ i++ i {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		} {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		} 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(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0)) System.out.println System.out System System.out counts[r - 1]  - (l > 0 ? counts [l - 1] : 0) counts[r - 1] counts r - 1 r 1 (l > 0 ? counts [l - 1] : 0) l > 0 l 0 counts [l - 1] counts l - 1 l 1 0 String str str int numOfQuestion numOfQuestion Scanner sc sc // 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	} countAC {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	} int[] counts = new int[str.length() - 1]; counts new int[str.length() - 1] str.length() - 1 str.length() str.length str 1 char[] chars = str.toCharArray(); chars str.toCharArray() str.toCharArray str int len = chars.length; len chars.length chars chars.length int count = 0; count 0 for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		} int i = 0; int i = 0; i 0 i < len - 1 i len - 1 len 1 i++ i++ i {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		} {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		} if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			} chars[i] == 'A' && chars[i + 1] == 'C' chars[i] == 'A' chars[i] chars i 'A' chars[i + 1] == 'C' chars[i + 1] chars i + 1 i 1 'C' {
				count++;
			} count++ count counts[i] = count counts[i] counts i count return counts; counts String str str public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
}
