import java.util.*;

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[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		}
		int[] rui = new int[n];
		String ac = "AC";
		rui[0] = 0;
		for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		}
		System.out.println();
		for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		}
	}
} import java.util.*; util.* java 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[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		}
		int[] rui = new int[n];
		String ac = "AC";
		rui[0] = 0;
		for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		}
		System.out.println();
		for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		}
	}
} 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[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		}
		int[] rui = new int[n];
		String ac = "AC";
		rui[0] = 0;
		for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		}
		System.out.println();
		for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		}
		int[] rui = new int[n];
		String ac = "AC";
		rui[0] = 0;
		for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		}
		System.out.println();
		for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		}
	} 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[] l = new int[q]; l new int[q] q int[] r = new int[q]; r new int[q] q for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		} {
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		} l[i] = sc.nextInt()-1 l[i] l i sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 r[i] = sc.nextInt()-1 r[i] r i sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int[] rui = new int[n]; rui new int[n] n String ac = "AC"; ac "AC" rui[0] = 0 rui[0] rui 0 0 for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		} {
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		} if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			} ac.equals(s.substring(i-1,i+1)) ac.equals ac s.substring(i-1,i+1) s.substring s i-1 i 1 i+1 i 1 {
				rui[i]++;
			} rui[i]++ rui[i] rui i rui[i]+=rui[i-1] rui[i] rui i rui[i-1] rui i-1 i 1 System.out.println() System.out.println System.out System System.out for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		} {
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		} System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]) System.out.println System.out System System.out l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]] l[i]!=0 l[i] l i 0 rui[r[i]]-rui[l[i]] rui[r[i]] rui r[i] r i rui[l[i]] rui l[i] l i rui[r[i]] rui r[i] r i String args[] args
import java.util.*;

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[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
			l[i] = sc.nextInt()-1;
			r[i] = sc.nextInt()-1;
		}
		int[] rui = new int[n];
		String ac = "AC";
		rui[0] = 0;
		for(int i = 1; i < n; i++){
			if(ac.equals(s.substring(i-1,i+1))){
				rui[i]++;
			}
			rui[i]+=rui[i-1];
		}
		System.out.println();
		for(int i = 0; i < q; i++){
			System.out.println(l[i]!=0?rui[r[i]]-rui[l[i]]:rui[r[i]]);
		}
	}
}
