import java.util.*;
public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
} import java.util.*; util.* java public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
} Main public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    } accumulate {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    } for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    } int i=1; int i=1; i 1 i<array.length i array.length array array.length i++ i++ i {
    	array[i] += array[i-1];
    } {
    	array[i] += array[i-1];
    } array[i] += array[i-1] array[i] array i array[i-1] array i-1 i 1 return array; array int[] array array public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	} main {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc Q = sc.nextInt(); Q sc.nextInt() sc.nextInt sc String S = sc.next(); S sc.next() sc.next sc int[] numArray = new int [N]; numArray new int [N] N for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    } int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    } {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    } numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0 numArray[i+1] numArray i+1 i 1 (S.substring(i,i+2).equals("AC"))? 1: 0 (S.substring(i,i+2).equals("AC")) S.substring(i,i+2).equals S.substring(i,i+2) S.substring S i i+2 i 2 "AC" 1 0 int[] sumArray = accumulate(numArray); sumArray accumulate(numArray) accumulate numArray for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    } int q=0; int q=0; q 0 q<Q q Q q++ q++ q {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    } {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    } int l = sc.nextInt()-1 l sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 r = sc.nextInt()-1; r sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int ans = sumArray[r] - sumArray[l]; ans sumArray[r] - sumArray[l] sumArray[r] sumArray r sumArray[l] sumArray l System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
} public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
} Main
import java.util.*;
public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+2).equals("AC"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
}