import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    } main {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    } 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[] count = new int[N+2]; count new int[N+2] N+2 N 2 for(int i = 0; i< N+2; i++) count[i] = 0; int i = 0; int i = 0; i 0 i< N+2 i N+2 N 2 i++ i++ i count[i] = 0; count[i] = 0 count[i] count i 0 for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        } int i = 0; int i = 0; i 0 i< N-1 i N-1 N 1 i++ i++ i {
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        } {
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        } String Ssub = S.substring(i, i+2); Ssub S.substring(i, i+2) S.substring S i i+2 i 2 if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            } Ssub.equals("AC") Ssub.equals Ssub "AC" {
                count[i+1] = count[i] + 1;
            } count[i+1] = count[i] + 1 count[i+1] count i+1 i 1 count[i] + 1 count[i] count i 1 {
                count[i+1] = count[i];
            } count[i+1] = count[i] count[i+1] count i+1 i 1 count[i] count i int ans = 0; ans 0 for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        } {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        } int l = sc.nextInt() - 1; l sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int r = sc.nextInt() - 1; r sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 ans = count[r] - count[l] ans count[r] - count[l] count[r] count r count[l] count l System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();

        int[] count = new int[N+2];
        for(int i = 0; i< N+2; i++) count[i] = 0;
        
        for(int i = 0; i< N-1; i++){
            String Ssub = S.substring(i, i+2);
            if(Ssub.equals("AC")){
                count[i+1] = count[i] + 1;
            }else{
                count[i+1] = count[i];
            }
        }

        int ans = 0;
        for(int i = 0; i < Q; i++){
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            ans = count[r] - count[l];
            System.out.println(ans);
        }
    }
}
