input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
Q = line[1] * 1 
S = lines.shift()
for (i=0; i<Q; i++) {
    line = lines[i].split(' ')
    l = line[0] * 1
    r = line[1] * 1
    cnt = 0
    for (j=l-1; j<r-1; j++) {
        if (S[j] == 'A' && S[j+1] == 'C') {
            cnt++
        }
    }
    console.log(cnt)
}
