"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = function (N, _Q, S, lrList) {
    var splitted = S.split('');
    var sList = [0];
    for (var i = 0; i < N; i++) {
        if (splitted[i] === 'A' && splitted[i + 1] === 'C') {
            sList.push(sList[i] + 1);
        }
        else {
            sList.push(sList[i]);
        }
    }
    var res = lrList.map(function (lr) {
        var l = lr[0] - 1;
        var r = lr[1] - 1;
        return sList[r] - sList[l];
    });
    return res;
};
var input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
var lines = input.split('\n');
var NQ = lines[0].split(' ');
var N = Number(NQ[0]);
var Q = Number(NQ[1]);
var S = lines[1];
var lrList = [];
for (var i = 0; i < Q; i++) {
    lrList.push(lines[2 + i].split(' ').map(function (l) { return Number(l); }));
}
var res = exports.main(N, Q, S, lrList);
res.forEach(function (r) { return console.log(r); });
