require "prime" N = gets.to_i ans = N.prime_division.map {|p, e| p}.select {|p| p >= 3}.min || N puts ans