N = gets.chomp.to_i 10000000 fizbuz = [] count = 0 for i in 1..10 ** 100 if (i % 5 == 0 and i % 3 == 0 and /^[35]*$/ =~ i.to_s) count += 1 if count == N puts i break end end end