import java.util.*;
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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
} import java.util.*; util.* java 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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
} 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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	} main {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	} 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[] ans = new int[N+1]; ans new int[N+1] N+1 N 1 for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		} int i=0; int i=0; i 0 i<=N-2 i N-2 N 2 i++ i++ i {
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		} {
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		} if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            } 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' {
				ans[i+2] += ans[i+1]+1;
			} ans[i+2] += ans[i+1]+1 ans[i+2] ans i+2 i 2 ans[i+1]+1 ans[i+1] ans i+1 i 1 1 {
				ans[i+2] += ans[i+1];              
            } ans[i+2] += ans[i+1] ans[i+2] ans i+2 i 2 ans[i+1] ans i+1 i 1 for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		} int i=0; int i=0; i 0 i<Q i Q i++ i++ i {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		} {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		} int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc System.out.println(ans[b] - ans[a]) System.out.println System.out System System.out ans[b] - ans[a] ans[b] ans b ans[a] ans a 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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
} 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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
} Main
import java.util.*;
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[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
}
