    n, q = gets.chomp.split.map(&:to_i)
    s = gets.chomp.to_s
    
    q.times do
      l, r = gets.chomp.split.map(&:to_i)
      count = 0
      
      p_s = s[l-1..r-1]
      
      loop{
      	unless p_s.include?('AC')
          puts count
          break
      	end
        p_s.sub!('AC','')
        count += 1
      }
    end