a = gets.to_s.split.map(&:to_i) while a[0] <= a[1] if a[0] % 3 == 0 puts a[0] else str = a[0].to_s str.length.times do |i| if str[i] == "3" puts a[0] break end end end a[0] += 1 end