import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} import java.io.PrintStream; PrintStream java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} Main static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	} exec {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	} 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 List<Integer> found = new ArrayList<>(); found new ArrayList<>() for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		} int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		} {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		} int r = S.indexOf("AC", i); r S.indexOf("AC", i) S.indexOf S "AC" i if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			} r >= 0 r 0 {
				found.add(r);
				i = r + "AC".length();
			} found.add(r) found.add found r i = r + "AC".length() i r + "AC".length() r "AC".length() "AC".length "AC" {
				break;
			} break; for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		} int i = 0; int i = 0; i 0 i < Q i Q i += 1 i += 1 i 1 {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		} {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		} int l = in.nextInt(); l in.nextInt() in.nextInt in int r = in.nextInt(); r in.nextInt() in.nextInt in int begin = Collections.binarySearch(found, l - 1); begin Collections.binarySearch(found, l - 1) Collections.binarySearch Collections found l - 1 l 1 if (begin < 0) {
				begin = -(begin + 1);
			} begin < 0 begin 0 {
				begin = -(begin + 1);
			} begin = -(begin + 1) begin -(begin + 1) (begin + 1) begin 1 int end = Collections.binarySearch(found, r - 1); end Collections.binarySearch(found, r - 1) Collections.binarySearch Collections found r - 1 r 1 if (end < 0) {
				end = -(end + 1);
			} end < 0 end 0 {
				end = -(end + 1);
			} end = -(end + 1) end -(end + 1) (end + 1) end 1 out.println(end - begin) out.println out end - begin end begin Scanner in in PrintStream out out public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	} main {
		exec(new Scanner(System.in), System.out);
	} exec(new Scanner(System.in), System.out) exec new Scanner(System.in) System.out System System.out String[] args args public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

} Main
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		List<Integer> found = new ArrayList<>();
		for (int i = 0; i < S.length();) {
			int r = S.indexOf("AC", i);
			if (r >= 0) {
				found.add(r);
				i = r + "AC".length();
			} else {
				break;
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			int begin = Collections.binarySearch(found, l - 1);
			if (begin < 0) {
				begin = -(begin + 1);
			}
			int end = Collections.binarySearch(found, r - 1);
			if (end < 0) {
				end = -(end + 1);
			}
			out.println(end - begin);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}
