import java.util.*;

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  [] list = new int [N + 1]; 
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        }

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        }
    }
} import java.util.*; util.* java 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  [] list = new int [N + 1]; 
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        }

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        }
    }
} 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  [] list = new int [N + 1]; 
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        }

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[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  [] list = new int [N + 1]; 
        int cnt = 0;
        
        for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        }

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[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  [] list = new int [N + 1]; list new int [N + 1] N + 1 N 1 int cnt = 0; cnt 0 for (int i = 0; i < N - 1; i++) {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        } int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        } {
            if ( S.substring(i, i + 2).equals("AC") ) cnt++;
            list[i + 2] = cnt; 
        } if ( S.substring(i, i + 2).equals("AC") ) cnt++; S.substring(i, i + 2).equals("AC") S.substring(i, i + 2).equals S.substring(i, i + 2) S.substring S i i + 2 i 2 "AC" cnt++ cnt list[i + 2] = cnt list[i + 2] list i + 2 i 2 cnt for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        } int q = 0; int q = 0; q 0 q < Q q Q q++ q++ q {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        } {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        } int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int ans = list[r] - list[l]; ans list[r] - list[l] list[r] list r list[l] list l 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 sc  = new Scanner(System.in);

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

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

        for (int q = 0; q < Q; q++ ) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = list[r] - list[l];

            System.out.println( ans ); 
        }
    }
}