import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	} main {
		Main main = new Main();
		main.solve();
	} Main main = new Main(); main new Main() main.solve() main.solve main String[] args args void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	} solve {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int q = Integer.parseInt(sc.next()); q Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String S = sc.next(); S sc.next() sc.next sc int[] dp = new int[n]; dp new int[n] n for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		} {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		} dp[i]=dp[i-1] dp[i] dp i dp[i-1] dp i-1 i 1 if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			} 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" {
				dp[i]++;
			} dp[i]++ dp[i] dp i for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		} int i=0; int i=0; i 0 i<q i q i++ i++ i {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		} {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		} int L = Integer.parseInt(sc.next()); L Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int R = Integer.parseInt(sc.next()); R Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc System.out.println((dp[R-1]-dp[L-1])) System.out.println System.out System System.out (dp[R-1]-dp[L-1]) dp[R-1] dp R-1 R 1 dp[L-1] dp L-1 L 1 sc.close() sc.close sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String S = sc.next();
		int[] dp = new int[n];
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1];
			if(S.substring(i-1, i+1).equals("AC")) {
				dp[i]++;
			}
		}
		for(int i=0;i<q;i++) {
			int L = Integer.parseInt(sc.next());
			int R = Integer.parseInt(sc.next());
			System.out.println((dp[R-1]-dp[L-1]));
		}
		sc.close();
	}
}
