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