
import java.util.Scanner;


public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

} Main public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  } main {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int q = s.nextInt(); q s.nextInt() s.nextInt s int[] outputs = new int[q]; outputs new int[q] q String str = s.next(); str s.next() s.next s int[] acs = new int[n]; acs new int[n] n acs[0] = 0 acs[0] acs 0 0 for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    } int i = 1; int i = 1; i 1 i < n i n i ++ i ++ i {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    } {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    } if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1]; str.substring(i - 1, i + 1).equals("AC") str.substring(i - 1, i + 1).equals str.substring(i - 1, i + 1) str.substring str i - 1 i 1 i + 1 i 1 "AC" acs[i] = acs[i - 1] + 1 acs[i] acs i acs[i - 1] + 1 acs[i - 1] acs i - 1 i 1 1 acs[i] = acs[i - 1] acs[i] acs i acs[i - 1] acs i - 1 i 1 for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    } int i = 0; int i = 0; i 0 i < q i q i ++ i ++ i {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    } {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    } int l = s.nextInt(); l s.nextInt() s.nextInt s int r = s.nextInt(); r s.nextInt() s.nextInt s outputs[i] = acs[r - 1] - acs[l - 1] outputs[i] outputs i acs[r - 1] - acs[l - 1] acs[r - 1] acs r - 1 r 1 acs[l - 1] acs l - 1 l 1 for (int i : outputs)
      System.out.println(i); int i outputs System.out.println(i); System.out.println(i) System.out.println System.out System System.out i String [] args args public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

} public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

} Main

import java.util.Scanner;


public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

}