n, q = gets.split.map(&:to_i)
s = gets.chomp
lr = q.times.map { gets.split.map(&:to_i) }
arr = Array.new(n, 0)
(1..n-1).each { |i| arr[i] = arr[i-1] + (s[i-1..i] == "AC" ? 1 : 0) }
puts lr.map{ |m| arr[m[1]-1] - arr[m[0]-1] }