

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	} 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 str = sc.next(); str sc.next() sc.next sc int leftAC[] = new int[n]; leftAC new int[n] n for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		} int i = n - 2; int i = n - 2; i n - 2 n 2 i >= 0 i 0 i-- i-- i {
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		} {
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		} leftAC[i] = leftAC[i + 1] leftAC[i] leftAC i leftAC[i + 1] leftAC i + 1 i 1 if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			} str.substring(i, i + 2).equals("AC") str.substring(i, i + 2).equals str.substring(i, i + 2) str.substring str i i + 2 i 2 "AC" {
				leftAC[i]++;
			} leftAC[i]++ leftAC[i] leftAC i for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		} {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		} 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(leftAC[l] - leftAC[r]) System.out.println System.out System System.out leftAC[l] - leftAC[r] leftAC[l] leftAC l leftAC[r] leftAC r String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();

		int leftAC[] = new int[n];

		for(int i = n - 2; i >= 0; i--){
			leftAC[i] = leftAC[i + 1];
			if(str.substring(i, i + 2).equals("AC")){
				leftAC[i]++;
			}
		}

		for(int i = 0; i < q; i++){
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;

			System.out.println(leftAC[l] - leftAC[r]);
		}
	}
}