import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  }
} Main public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  } main {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    } in.hasNext() in.hasNext in {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    } int N = in.nextInt(); N in.nextInt() in.nextInt in int Q = in.nextInt(); Q in.nextInt() in.nextInt in String S = in.next(); S in.next() in.next in int[] countAC = new int[N]; countAC new int[N] N for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      } int i  = 1; int i  = 1; i 1 i < S.length() i S.length() S.length S ++i ++i i {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      } {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      } countAC[i] = countAC[i - 1] countAC[i] countAC i countAC[i - 1] countAC i - 1 i 1 if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        } S.charAt(i - 1) == 'A' && S.charAt(i) == 'C' S.charAt(i - 1) == 'A' S.charAt(i - 1) S.charAt S i - 1 i 1 'A' S.charAt(i) == 'C' S.charAt(i) S.charAt S i 'C' {
          ++countAC[i];
        } ++countAC[i] countAC[i] countAC i while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      } Q-- > 0 Q-- Q 0 {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      } int l = in.nextInt() - 1; l in.nextInt() - 1 in.nextInt() in.nextInt in 1 int r = in.nextInt() - 1; r in.nextInt() - 1 in.nextInt() in.nextInt in 1 System.out.println(countAC[r] - countAC[l]) System.out.println System.out System System.out countAC[r] - countAC[l] countAC[r] countAC r countAC[l] countAC l String[] args args public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  }
} public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int Q = in.nextInt();
      String S = in.next();
      int[] countAC = new int[N];

      for (int i  = 1; i < S.length(); ++i) {
        countAC[i] = countAC[i - 1];

        if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C') {
          ++countAC[i];
        }
      }

      while (Q-- > 0) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;

        System.out.println(countAC[r] - countAC[l]);
      }
    }
  }
}