import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
} import java.io.IOException; IOException java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc Q = sc.nextInt(); Q sc.nextInt() sc.nextInt sc String S = sc.next(); S sc.next() sc.next sc int A[] = new int[S.length() + 1]; A new int[S.length() + 1] S.length() + 1 S.length() S.length S 1 for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    } int i = 1; int i = 1; i 1 i < S.length() i S.length() S.length S i++ i++ i {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    } {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    } if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      } 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' {
        A[i] = 1;
      } A[i] = 1 A[i] A i 1 {
        A[i] = 0;
      } A[i] = 0 A[i] A i 0 int PSA[] = new int[S.length() + 1]; PSA new int[S.length() + 1] S.length() + 1 S.length() S.length S 1 for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    } int i = 1; int i = 1; i 1 i <= S.length() i S.length() S.length S i++ i++ i {
      PSA[i] = PSA[i - 1] + A[i];
    } {
      PSA[i] = PSA[i - 1] + A[i];
    } PSA[i] = PSA[i - 1] + A[i] PSA[i] PSA i PSA[i - 1] + A[i] PSA[i - 1] PSA i - 1 i 1 A[i] A i for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    } {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    } int l = sc.nextInt() l sc.nextInt() sc.nextInt sc r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int result = PSA[r - 1] - PSA[l - 1]; result PSA[r - 1] - PSA[l - 1] PSA[r - 1] PSA r - 1 r 1 PSA[l - 1] PSA l - 1 l 1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
} public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
} Main
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
}
