2.times do a = gets.chomp unless a == "0" || a =~ /^[1-9]\d*$/ && a.to_i < 12346 puts "NG" exit end end puts "OK"