object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    println(solve(sc))
  }

  def solve(sc: Scanner): String = {
    val (n, q) = (sc.nextInt(), sc.nextInt())
    val s = sc.next().split("").filter(!_.isEmpty).toSeq
    val lrs = (1 to q).map(_ => (sc.nextInt(), sc.nextInt()))
    debug(n, q, s, lrs)

    lrs.map { case (l, r) =>
      s.slice(l - 1, r).sliding(2).map(_.mkString).count(_ == "AC")
    }.mkString("\n")
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}
