import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	}
} import java.util.*; util.* java public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	} 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 String S2 = S.replaceAll("AC","10"); S2 S.replaceAll("AC","10") S.replaceAll S "AC" "10" int [] AC = new int [N]; AC new int [N] N if (S2.charAt(0) == '1')
			
			AC[0] = 1; S2.charAt(0) == '1' S2.charAt(0) S2.charAt S2 0 '1' AC[0] = 1 AC[0] AC 0 1 for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		} {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		} if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1]; S2.charAt(i) == '1' S2.charAt(i) S2.charAt S2 i '1' AC[i] = AC[i-1] + 1 AC[i] AC i AC[i-1] + 1 AC[i-1] AC i-1 i 1 1 AC[i] = AC[i-1] AC[i] AC i AC[i-1] AC i-1 i 1 int l; l int r; r for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		} int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		} {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		} l = sc.nextInt() l sc.nextInt() sc.nextInt sc r = sc.nextInt() r sc.nextInt() sc.nextInt sc if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]); l == 1 l 1 System.out.println(AC[r-2]) System.out.println System.out System System.out AC[r-2] AC r-2 r 2 System.out.println(AC[r-2] - AC[l-2]) System.out.println System.out System System.out AC[r-2] - AC[l-2] AC[r-2] AC r-2 r 2 AC[l-2] AC l-2 l 2 String[] args args public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	}
} public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	}
} Main
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S  = sc.next();
		
		String S2 = S.replaceAll("AC","10");
		//System.out.println(S2);
		int [] AC = new int [N];
			//System.out.println(S2.charAt(0));
			//System.out.println(S2.charAt(0) == '1');
		if (S2.charAt(0) == '1')
			
			AC[0] = 1;
		for (int i = 1; i < N; i++) {
			if (S2.charAt(i) == '1')
				AC[i] = AC[i-1] + 1;
			else
				AC[i] = AC[i-1];
			//System.out.print(AC[i]);
		}
		int l;
		int r;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			if (l == 1)
				System.out.println(AC[r-2]);
			else
				System.out.println(AC[r-2] - AC[l-2]);
		}
	}
}
