import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int q = scan.nextInt();
      	String word = scan.next();
      	int[] nums = new int[2*q];
      	for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        }
     	int[] ac = new int[word.length()];
      	ac[0] = 0;
      	for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        }
      	int ans = 0;
      	for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        }
    }
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int q = scan.nextInt();
      	String word = scan.next();
      	int[] nums = new int[2*q];
      	for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        }
     	int[] ac = new int[word.length()];
      	ac[0] = 0;
      	for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        }
      	int ans = 0;
      	for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        }
    }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int q = scan.nextInt();
      	String word = scan.next();
      	int[] nums = new int[2*q];
      	for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        }
     	int[] ac = new int[word.length()];
      	ac[0] = 0;
      	for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        }
      	int ans = 0;
      	for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        }
    } main {
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int q = scan.nextInt();
      	String word = scan.next();
      	int[] nums = new int[2*q];
      	for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        }
     	int[] ac = new int[word.length()];
      	ac[0] = 0;
      	for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        }
      	int ans = 0;
      	for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int q = scan.nextInt(); q scan.nextInt() scan.nextInt scan String word = scan.next(); word scan.next() scan.next scan int[] nums = new int[2*q]; nums new int[2*q] 2*q 2 q for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        } int i=0; int i=0; i 0 i<2*q i 2*q 2 q i++ i++ i {
        	nums[i] = scan.nextInt();
        } {
        	nums[i] = scan.nextInt();
        } nums[i] = scan.nextInt() nums[i] nums i scan.nextInt() scan.nextInt scan int[] ac = new int[word.length()]; ac new int[word.length()] word.length() word.length word ac[0] = 0 ac[0] ac 0 0 for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        } int i=1; int i=1; i 1 i<word.length() i word.length() word.length word i++ i++ i {
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        } {
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        } if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            } word.substring(i-1,i+1).equals("AC") word.substring(i-1,i+1).equals word.substring(i-1,i+1) word.substring word i-1 i 1 i+1 i 1 "AC" {
            	ac[i] = ac[i-1]+1;
            } ac[i] = ac[i-1]+1 ac[i] ac i ac[i-1]+1 ac[i-1] ac i-1 i 1 1 {
            	ac[i] = ac[i-1];
            } ac[i] = ac[i-1] ac[i] ac i ac[i-1] ac i-1 i 1 int ans = 0; ans 0 for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        } int i=0; int i=0; i 0 i<q i q i++ i++ i {
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        } {
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        } ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1] ans -ac[nums[2*i]-1] + ac[nums[2*i+1]-1] -ac[nums[2*i]-1] ac[nums[2*i]-1] ac nums[2*i]-1 nums[2*i] nums 2*i 2 i 1 ac[nums[2*i+1]-1] ac nums[2*i+1]-1 nums[2*i+1] nums 2*i+1 2*i 2 i 1 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int q = scan.nextInt();
      	String word = scan.next();
      	int[] nums = new int[2*q];
      	for(int i=0;i<2*q;i++){
        	nums[i] = scan.nextInt();
        }
     	int[] ac = new int[word.length()];
      	ac[0] = 0;
      	for(int i=1;i<word.length();i++){
        	if(word.substring(i-1,i+1).equals("AC")){
            	ac[i] = ac[i-1]+1;
            } else {
            	ac[i] = ac[i-1];
            }
        }
      	int ans = 0;
      	for(int i=0;i<q;i++){
        	ans = -ac[nums[2*i]-1] + ac[nums[2*i+1]-1];
          	System.out.println(ans);
        }
    }
}