import java.util.Scanner;



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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
} import java.util.Scanner; Scanner 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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
} 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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-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 a[] = new int[N+1]; a new int[N+1] N+1 N 1 int count =0; count 0 a[0] =0 a[0] a 0 0 for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		} int i=0; int i=0; i 0 i<S.length()-1 i S.length()-1 S.length() S.length S 1 i++ i++ i {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		} {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		} if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			} S.charAt(i)=='A'&&S.charAt(i+1)=='C' S.charAt(i)=='A' S.charAt(i) S.charAt S i 'A' S.charAt(i+1)=='C' S.charAt(i+1) S.charAt S i+1 i 1 'C' {
				count ++;
			} count ++ count a[i+1]=count a[i+1] a i+1 i 1 count for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		} int i=0; int i=0; i 0 i<Q i Q i++ i++ i {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		} {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		} int start = sc.nextInt(); start sc.nextInt() sc.nextInt sc int end =sc.nextInt(); end sc.nextInt() sc.nextInt sc System.out.println(a[end-1]-a[start-1]) System.out.println System.out System System.out a[end-1]-a[start-1] a[end-1] a end-1 end 1 a[start-1] a start-1 start 1 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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
} 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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
} Main
import java.util.Scanner;



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();
		int a[] = new int[N+1];
		int count =0;
		a[0] =0;
		for (int i=0;i<S.length()-1;i++) {
			if (S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
				count ++;
			}
			a[i+1]=count;
		}
		for (int i=0;i<Q;i++) {
			int start = sc.nextInt();
			int end =sc.nextInt();
			System.out.println(a[end-1]-a[start-1]);
		}
	}
}
