# frozen_string_literal: true require 'prime' def solve N.divisors.select { |i| i > 2 }.min end # @see https://qiita.com/seinosuke/items/fde2e0471dcf937e5a09 class Integer def divisors return [1] if self == 1 first, *rest = Prime.prime_division(self).map do |p, k| (0..k).map { |i| p**i } end first.product(*rest).map { |a| a.inject(&:*) }.sort end end N = gets.to_i puts solve