require "prime" N = gets.to_i x = 0 N.times{ x += 1 x += 1 while x.prime_division.map{|pr, n|n+1}.inject(:*) != 4 } p x