import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        }
}//0=48
//鶏になれ import java.util.*; util.* java public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        }
}//0=48 Main public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        } main {
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc boolean ebishu = true; ebishu true sc.close() sc.close sc while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                } ebishu {
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                } for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        } int i = 2 ; int i = 2 ; i 2 i <= Math.sqrt(n) i Math.sqrt(n) Math.sqrt Math n i++ i++ i {
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        } {
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        } if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                } (Math.log10(n) / Math.log10(i)) % 1 == 0 (Math.log10(n) / Math.log10(i)) % 1 (Math.log10(n) / Math.log10(i)) Math.log10(n) Math.log10 Math n Math.log10(i) Math.log10 Math i 1 0 {
                                        ebishu = false;
                                } ebishu = false ebishu false n-- n if(n == 0) ebishu = false; n == 0 n 0 ebishu = false ebishu false n++ n System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        }
}//0=48 public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        }
}//0=48 Main
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                boolean ebishu = true;
                sc.close();
                while(ebishu){
                        for(int i = 2 ; i <= Math.sqrt(n) ; i++){
                                if((Math.log10(n) / Math.log10(i)) % 1 == 0){
                                        ebishu = false;
                                }
                        }
                        n--;
                        if(n == 0) ebishu = false;
                }
                n++;
                System.out.println(n);

        }
}//0=48
//鶏になれ