import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan String g = scan.next(); g scan.next() scan.next scan int count = 0; count 0 int[] a = new int[n]; a new int[n] n for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    } {
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    } if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      } (g.charAt(i) == 'A') && (g.charAt(i+1) == 'C') (g.charAt(i) == 'A') g.charAt(i) g.charAt g i 'A' (g.charAt(i+1) == 'C') g.charAt(i+1) g.charAt g i+1 i 1 'C' {
        count += 1;
      } count += 1 count 1 a[i] = count a[i] a i count a[n-1] = a[n-2] a[n-1] a n-1 n 1 a[n-2] a n-2 n 2 for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    } int j = 0; int j = 0; j 0 j<m j m j++ j++ j {
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    } {
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    } int start = scan.nextInt(); start scan.nextInt() scan.nextInt scan int end = scan.nextInt(); end scan.nextInt() scan.nextInt scan int modify = 0; modify 0 if (start == end){
        System.out.println(0);
        continue;
      } start == end start end {
        System.out.println(0);
        continue;
      } System.out.println(0) System.out.println System.out System System.out 0 continue; if (a[end-1] > a[end-2]){
        modify += 1;
      } a[end-1] > a[end-2] a[end-1] a end-1 end 1 a[end-2] a end-2 end 2 {
        modify += 1;
      } modify += 1 modify 1 if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      } (g.charAt(start-1) == 'A') && (g.charAt(start) == 'C') (g.charAt(start-1) == 'A') g.charAt(start-1) g.charAt g start-1 start 1 'A' (g.charAt(start) == 'C') g.charAt(start) g.charAt g start 'C' {
        modify -= 1;
      } modify -= 1 modify 1 System.out.println(a[end-1] - a[start-1]-modify) System.out.println System.out System System.out a[end-1] - a[start-1]-modify a[end-1] - a[start-1]-modify a[end-1] a end-1 end 1 a[start-1] a start-1 start 1 modify String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    String g = scan.next();

    int count = 0;
    int[] a = new int[n];
    for (int i=0;i<n-1;i++){
      if ((g.charAt(i) == 'A') && (g.charAt(i+1) == 'C')){
        count += 1;
      }
      a[i] = count;
    }
    a[n-1] = a[n-2];

    for (int j = 0; j<m ;j++){
      int start = scan.nextInt();
      int end = scan.nextInt();
      int modify = 0;
      if (start == end){
        System.out.println(0);
        continue;
      }
      if (a[end-1] > a[end-2]){
        modify += 1;
      }
      if ((g.charAt(start-1) == 'A') && (g.charAt(start) == 'C')){
        modify -= 1;
      }
      System.out.println(a[end-1] - a[start-1]-modify);
    }
  }
}
