import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	} 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 String S = sc.next(); S sc.next() sc.next sc int l[] = new int[Q]; l new int[Q] Q int r[] = new int[Q]; r new int[Q] Q for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		} l[i] = sc.nextInt() l[i] l i sc.nextInt() sc.nextInt sc r[i] = sc.nextInt() r[i] r i sc.nextInt() sc.nextInt sc int ans[] = new int[Q]; ans new int[Q] Q int t[] = new int[N+1]; t new int[N+1] N+1 N 1 t[0] =  0 t[0] t 0 0 for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		} {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		} if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[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" {
				t[i] = t[i-1] + 1;
			} t[i] = t[i-1] + 1 t[i] t i t[i-1] + 1 t[i-1] t i-1 i 1 1 {
				t[i] = t[i-1];
			} t[i] = t[i-1] t[i] t i t[i-1] t i-1 i 1 for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		} int i = 0; int i = 0; i 0 i < ans.length i ans.length ans ans.length i++ i++ i {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		} {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		} System.out.println(t[r[i]-1]-t[l[i]-1]) System.out.println System.out System System.out t[r[i]-1]-t[l[i]-1] t[r[i]-1] t r[i]-1 r[i] r i 1 t[l[i]-1] t l[i]-1 l[i] l i 1 String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
}
