'use strict'
function main(input) {
  input = input.trim().split('\n')
  input.shift()
  const S = input.shift()
  const ans = []

  input.forEach(val => {
    const LR = val.split(' ').map(v => Number(v))
    const match = S.slice(LR[0]-1, LR[1]).match(/AC/g)
    ans.push(match ? match.length : 0)
  })

  console.log(ans.join('\n'));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
