function splitMap(input) {
  return input.split(' ').map(s => parseInt(s, 10))
}

function main(input) {
  const [o, t, ...ql] = input.split('\n')
  const [length, ac] = splitMap(o)
  const qs = ql.map(q => splitMap(q))
  
  let map = []
  let count = 0
  for (let i = 0; i < length; i++) {
	map[i] = t[i] + t[i + 1] === 'AC' ? count++ : count
  }
  
  let mes = ''
  for (let i = 0; i < ac; i++) {
    const [s, e] = qs[i]
    const result = map[s - 1] - map[e - 1]
    mes += `${result} \n`
  }
  
  return mes
}

console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")))