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