import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  }
} Main public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  } main {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int N = scn.nextInt(); N scn.nextInt() scn.nextInt scn int Q = scn.nextInt(); Q scn.nextInt() scn.nextInt scn scn.nextLine() scn.nextLine scn String S = scn.nextLine(); S scn.nextLine() scn.nextLine scn int[] L = new int[N]; L new int[N] N L[0] = 0 L[0] L 0 0 for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    } {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    } if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      } S.substring(i - 1, i + 1).equals("AC") S.substring(i - 1, i + 1).equals S.substring(i - 1, i + 1) S.substring S i - 1 i 1 i + 1 i 1 "AC" {
        L[i] = L[i - 1] + 1;
      } L[i] = L[i - 1] + 1 L[i] L i L[i - 1] + 1 L[i - 1] L i - 1 i 1 1 {
        L[i] = L[i - 1];
      } L[i] = L[i - 1] L[i] L i L[i - 1] L i - 1 i 1 for (int i = 0; i < Q; i++) {
      int l = scn.nextInt() - 1;
      int r = scn.nextInt() - 1;
      System.out.println(L[r] - L[l]);
    } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
      int l = scn.nextInt() - 1;
      int r = scn.nextInt() - 1;
      System.out.println(L[r] - L[l]);
    } {
      int l = scn.nextInt() - 1;
      int r = scn.nextInt() - 1;
      System.out.println(L[r] - L[l]);
    } int l = scn.nextInt() - 1; l scn.nextInt() - 1 scn.nextInt() scn.nextInt scn 1 int r = scn.nextInt() - 1; r scn.nextInt() - 1 scn.nextInt() scn.nextInt scn 1 System.out.println(L[r] - L[l]) System.out.println System.out System System.out L[r] - L[l] L[r] L r L[l] L l String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  }
} public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int Q = scn.nextInt();
    scn.nextLine();
    String S = scn.nextLine();

    int[] L = new int[N];
    L[0] = 0;
    for (int i = 1; i < N; i++) {

      if (S.substring(i - 1, i + 1).equals("AC")) {
        L[i] = L[i - 1] + 1;
      } else {
        L[i] = L[i - 1];
      }
    }

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

  }
}