import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

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

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  } 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 long[] a=new long[n+1]; a new long[n+1] n+1 n 1 for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    } int i=2; int i=2; i 2 i<=s.length() i s.length() s.length s i++ i++ i {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    } {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    } if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1]; s.substring(i-2, i).equals("AC") s.substring(i-2, i).equals s.substring(i-2, i) s.substring s i-2 i 2 i "AC" a[i]=a[i-1]+1L a[i] a i a[i-1]+1L a[i-1] a i-1 i 1 1L a[i]=a[i-1] a[i] a i a[i-1] a i-1 i 1 for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    } int i=0; int i=0; i 0 i<q i q i++ i++ i {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    } {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    } int l=sc.nextInt() l sc.nextInt() sc.nextInt sc r=sc.nextInt(); r sc.nextInt() sc.nextInt sc System.out.println(a[r]-a[l]) System.out.println System.out System System.out a[r]-a[l] a[r] a r a[l] a l String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  }
} Main
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),q=sc.nextInt();
    String s=sc.next();
    long[] a=new long[n+1];
    for(int i=2;i<=s.length();i++) {
    	if(s.substring(i-2, i).equals("AC"))a[i]=a[i-1]+1L;
    	else a[i]=a[i-1];
    }

    for(int i=0;i<q;i++) {
    	int l=sc.nextInt(),r=sc.nextInt();
    	System.out.println(a[r]-a[l]);
    }
  }
}
