hel=["A","C","G","T"]

a = []
a = gets.split.map(&:to_i)
#p hel

n = gets.chomp
x = n.chars
#p x

c = []
while s = gets
  c.push(s.split.map(&:to_i))
end

cnt = [0]
t = 0
for i in 1..a[0]-1
    if x[i]=="C"
        if x[i-1]=="A"
            t+=1
        end
    end
cnt.push(t)
end

for i in 0..a[1]-1
    puts cnt[c[i][1]-1]-cnt[c[i][0]-1]
end
#puts c[2][0]




#p a
#p x
#p c
#p cnt