import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n1 = sc.nextInt(); n1 sc.nextInt() sc.nextInt sc int n2 = sc.nextInt(); n2 sc.nextInt() sc.nextInt sc int c1 = 0 c1 0 c2 = 0; c2 0 String s = sc.next(); s sc.next() sc.next sc int count=0; count 0 int box[]=new int[n1]; box new int[n1] n1 boolean ac = false; ac false for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    } int i = 0; int i = 0; i 0 i < n1-1 i n1-1 n1 1 i++ i++ i {
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    } {
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[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 box[i+1]=count box[i+1] box i+1 i 1 count for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    } int l = 0; int l = 0; l 0 l < n2 l n2 l++ l++ l {
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    } {
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    } c1 = sc.nextInt() c1 sc.nextInt() sc.nextInt sc c2 = sc.nextInt() c2 sc.nextInt() sc.nextInt sc System.out.println(box[c2-1]-box[c1-1]) System.out.println System.out System System.out box[c2-1]-box[c1-1] box[c2-1] box c2-1 c2 1 box[c1-1] box c1-1 c1 1 String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int c1 = 0,c2 = 0;
    String s = sc.next();
    int count=0;
    int box[]=new int[n1];
    boolean ac = false;
    for(int i = 0;i < n1-1;i++){
        if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
          count++;
    	}
      box[i+1]=count;
    }
    for(int l = 0;l < n2;l++){
      c1 = sc.nextInt();
      c2 = sc.nextInt();
      System.out.println(box[c2-1]-box[c1-1]);
    }
  }
}