object Main {
  val sc = new java.util.Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val Q = sc.nextInt
    val S = sc.next
    val list = Array.fill(Q, 2)(sc.nextInt)

    list.foreach{ case Array(l, r) =>
        val sub = S.substring(l-1, r)
        var count = 0
        for (i <- 0 until sub.length - 1) {
          val l: String = sub.charAt(i).toString + sub.charAt(i + 1).toString
          if(l == "AC"){
            count = count + 1
          }
        }
        println(count)
    }
  }
}