import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 出力
		//System.out.println(result);
        
	}
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import java.math.BigInteger; BigInteger java.math 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[] list = new int[n + 1];
		int cnt = 0;
		for(int i = 0; i < n - 1; i++){
		    if(s.substring(i, i + 2).equals("AC")){
		        cnt++;
		    }
		    list[i + 2] = cnt;
		}
		for(int i = 0; i < q; i++){
		    int l = sc.nextInt();
		    int r = sc.nextInt();
		    int result = list[r] - list[l];
		    System.out.println(result);
		}

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

		// 出力
		//System.out.println(result);
        
	} main {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		
		// 計算
		int[] list = new int[n + 1];
		int cnt = 0;
		for(int i = 0; i < n - 1; i++){
		    if(s.substring(i, i + 2).equals("AC")){
		        cnt++;
		    }
		    list[i + 2] = cnt;
		}
		for(int i = 0; i < q; i++){
		    int l = sc.nextInt();
		    int r = sc.nextInt();
		    int result = list[r] - list[l];
		    System.out.println(result);
		}

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

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

		// 出力
		//System.out.println(result);
        
	}
} Main
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 出力
		//System.out.println(result);
        
	}
}
