one_yen, five_yen = gets.chomp.split.map(&:to_i) list, sum = Array.new, 0 one_yen_list, five_yen_list = Array.new, Array.new 1.upto(one_yen){ one_yen_list << sum += 1 } sum = 0 1.upto(five_yen){ five_yen_list << sum += 5 } one_yen_list.each do |one| five_yen_list.each do |five| list << one += five one -= five end end puts (one_yen_list + five_yen_list + list).uniq.sort