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 str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
} 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 str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    String str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  } main {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    String str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  } 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 str = sc.next(); str sc.next() sc.next sc String[] strList = str.split(""); strList str.split("") str.split str "" int[] t = new int[n + 1]; t new int[n + 1] n + 1 n 1 for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    } {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    } if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      } strList[i-1].equals("A") && strList[i].equals("C") strList[i-1].equals("A") strList[i-1].equals strList[i-1] strList i-1 i 1 "A" strList[i].equals("C") strList[i].equals strList[i] strList i "C" {
        t[i + 1] = t[i] + 1;
      } t[i + 1] = t[i] + 1 t[i + 1] t i + 1 i 1 t[i] + 1 t[i] t i 1 {
        t[i + 1] = t[i];
      } t[i + 1] = t[i] t[i + 1] t i + 1 i 1 t[i] t i for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    } {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    } int start = sc.nextInt(); start sc.nextInt() sc.nextInt sc int end = sc.nextInt(); end sc.nextInt() sc.nextInt sc System.out.println(t[end] - t[start]) System.out.println System.out System System.out t[end] - t[start] t[end] t end t[start] t start 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 str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    String str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
} 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 str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
}
