function main(arg) {
	arg = arg.split("\n")
	arg.shift()
	var s = arg.shift().split("")
	arg = arg.map(e => e.split(" ").map(Number))
	for (var t = 0; t < arg.length; t++) {
		var count = 0
		for (var i = arg[t][0] - 1; i < arg[t][1] - 1; i++) {
			if (s[i] + s[i + 1] == 'AC') {
				count++
			}
		}
		console.log(count)
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));