import java.util.*; class A { static Scanner s = new Scanner(System.in); public static void main(String[] args) { long in = s.nextLong(); if(in%3==0) System.out.println(3); if(in%4==0) System.out.println(4); long l = (long)(Math.sqrt(in)+0.6); long c = 5; while(in%c!=0){ c+=2; if(c>l){ System.out.println(in); return; } } System.out.println(c); } }