import java.util.*; import java.io.*; import java.math.*; public class No312 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); for(long i = 3; i < n; i++) { if(isPrime(i)) { if(n%i == 0) { System.out.println(i); return; } } } } public static boolean isPrime(long num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = Math.sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } }