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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
} 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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
} 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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    } 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[] l = new int[q]; l new int[q] q int[] r = new int[q]; r new int[q] q for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        } int i = 0; int i = 0; i 0 i < r.length i r.length r r.length i++ i++ i {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        } {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        } l[i] = sc.nextInt() - 1 l[i] l i sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 r[i] = sc.nextInt() - 1 r[i] r i sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int[] a = new int[n]; a new int[n] n for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        } int i = 0; int i = 0; i 0 i < a.length - 1 i a.length - 1 a.length a a.length 1 i++ i++ i {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        } {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        } if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            } 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' {
                a[i]++;
            } a[i]++ a[i] a i int[] sum = new int[n + 1]; sum new int[n + 1] n + 1 n 1 for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
            sum[i + 1] = sum[i] + a[i]; 
        } {
            sum[i + 1] = sum[i] + a[i]; 
        } sum[i + 1] = sum[i] + a[i] sum[i + 1] sum i + 1 i 1 sum[i] + a[i] sum[i] sum i a[i] a i for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        } int i = 0; int i = 0; i 0 i < r.length i r.length r r.length i++ i++ i {
           System.out.println(sum[r[i]] - sum[l[i]]);
        } {
           System.out.println(sum[r[i]] - sum[l[i]]);
        } System.out.println(sum[r[i]] - sum[l[i]]) System.out.println System.out System System.out sum[r[i]] - sum[l[i]] sum[r[i]] sum r[i] r i sum[l[i]] sum l[i] l i sc.close() sc.close sc 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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
} 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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
} 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[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
}