import java.util.*;
import java.lang.*;

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[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    }
} import java.util.*; util.* java import java.lang.*; lang.* 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[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    }
} 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[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    } 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[] nums = new int[n]; nums new int[n] n for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        } {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        } nums[i + 1] = nums[i] nums[i + 1] nums i + 1 i 1 nums[i] nums i if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            } 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" {
                nums[i + 1]++;
            } nums[i + 1]++ nums[i + 1] nums i + 1 i 1 for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        } 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;
            
            System.out.println(nums[r] - nums[l]);
        } {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        } 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 System.out.println(nums[r] - nums[l]) System.out.println System.out System System.out nums[r] - nums[l] nums[r] nums r nums[l] nums l 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[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    }
} 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[] nums = new int[n];
        for (int i = 0; i < n - 1; i++) {
            nums[i + 1] = nums[i];
            if (s.substring(i, i + 2).equals("AC")) {
                nums[i + 1]++;
            }
            
        }
        
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            
            System.out.println(nums[r] - nums[l]);
        }
    }
} Main
import java.util.*;
import java.lang.*;

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