using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        static long mod = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            while (true)
            {
                if (IsPrime(n))
                {
                    Console.WriteLine(n);
                    Console.ReadLine();
                    return;
                }
                    n++;
            }

            Console.ReadLine();
        }
        public static long Factorial2(long n,long number, long mod)
        {
            if (n == 0) return 1;
            if (n == 1) return 1;
            long ans = n;
            for (long i = n-1; i > n-number; i--)
            {
                ans = (ans * i) % mod;
            }

            return ans;
        }

        static List<long> GetDivisor(long N)
        {
            List<long> ans = new List<long>();
            int max = (int)Math.Sqrt(N);
            for (int i = 1; i < max; i++)
            {
                if (N % i == 0)
                {
                    ans.Add(i);
                    ans.Add(N / i);
                }
            }

            if(N%max == 0)
            {
                if (N / max == max) ans.Add(max);
                else
                {
                    ans.Add(max);
                    ans.Add(N / max);
                }
            }
            return ans;
        }

        static bool IsPrime(int n)
        {
            if (n == 1) return false;
            for (int i = 2; i <= (int)Math.Sqrt(n); i++)
            {
                if (n % i == 0) return false;
            }
            return true;
        }

        static int[] BinarySearchSpace(List<long> sortedArray,long value)
        {
            int min = 0;
            int max = sortedArray.Count;

            if (value <= sortedArray[0]) return new int[2] { -1, 0 };
            if (value >= sortedArray[sortedArray.Count - 1]) return new int[2] { sortedArray.Count - 1,sortedArray.Count };

            while (max>min)
            {
                int mid = (min + max) / 2;
                if (sortedArray[mid] > value) max = mid;
                else if (sortedArray[mid] < value) min = mid;
                else return new int[2] { mid, mid + 1 };

                if (min == max - 1) return new int[2] { min, max };
            }
            return null;
        }


        static Dictionary<long,long> FindElements(long N)
        {
            long curN = N;
            Dictionary<long, long> elements = new Dictionary<long, long>();
           
            for (int i = 2; i <= (long)Math.Sqrt(N); i++)
            {
                while (curN%i==0)
                {
                    curN /= i;
                    if (elements.ContainsKey(i)) elements[i]++;
                    else elements.Add(i, 1);
                }
            }
            if(curN!=1)elements.Add(curN, 1);
            return elements;
        }

        public static long GetInv(long a, long mod)
        {
            return PowerMod(a, mod - 2, mod);
        }

        public static long Combination(long a, long b, long mod)
        {
            long numerator = Factorial(a, mod);
            long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;

            return (numerator * GetInv(denominator, mod)) % mod;
        }

        public static long Factorial(long n, long mod)
        {
            if (n == 0) return 1;
            if (n == 1) return 1;
            long ans = n;
            for (int i = 2; i < n; i++)
            {
                ans = (ans * i) % mod;
            }

            return ans;
        }




        private static long PowerMod(long a, long n, long mod)
        {
            if (n == 1) return a;

            long p = PowerMod(a, n / 2, mod);
            if (n % 2 == 1) return ((p * p) % mod * a) % mod;
            else return (p * p) % mod;
        }

        public static class Comb
        {
            public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition)
            {
                if (k == 1)
                {
                    foreach (var item in items)
                        yield return new T[] { item };
                    yield break;
                }
                foreach (var item in items)
                {
                    var leftside = new T[] { item };

                    // item よりも前のものを除く （順列と組み合わせの違い)
                    // 重複を許さないので、unusedから item そのものも取り除く
                    var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

                    foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                    {
                        yield return leftside.Concat(rightside).ToArray();
                    }
                }
            }
        }

        public class BFSClass
        {
            /// <summary>
            /// 1...道、2...障害物(0は未知)
            /// </summary>
            /// <param name="map"></param>
            public BFSClass(int[][] map)
            {
                Map = map;
            }

            private class TileFrom
            {
                public TileFrom(int[] thisTile, int[] from)
                {
                    ThisTile = thisTile;
                    From = from;
                }
                public int[] ThisTile { get; }
                public int[] From { get; }
            }

            public int[][] Map { get; }

            //調べる予定の位置を入れる
            Queue<int[]> search = new Queue<int[]>();

            //調べ終わった位置
            List<TileFrom> done = new List<TileFrom>();

            /// <summary>
            /// 
            /// </summary>
            /// <param name="map"></param>
            public int BFS(int[] startPos, int[] goalPos)
            {
                done.Add(new TileFrom(startPos, null));

                //現在の位置
                int[] currentPos = startPos;

                return StartBFS(0,currentPos, goalPos);
            }

            /// <summary>
            /// 終わったらtrue
            /// </summary>
            /// <param name="currentPos"></param>
            /// <param name="goalPos"></param>
            private int StartBFS(int currentCount,int[] currentPos, int[] goalPos)
            {
                if (currentPos.SequenceEqual(goalPos)) return currentCount;

                List<int[]> around = GetAroundTile(currentPos);
                foreach (var item in around)
                {
                    if (!done.Exists(i => i.ThisTile.SequenceEqual(item)))
                    {
                        done.Add(new TileFrom(item, currentPos));
                        search.Enqueue(item);
                        Console.WriteLine(item[0] + "," + item[1] + "を調べます");
                    }
                    else
                    {
                        Console.WriteLine(item[0] + "," + item[1] + "は済んでいます");
                    }
                }

                while (search.Count > 0)
                {
                    var nextStartPos = search.Dequeue();
                    if (Map[nextStartPos[0]][nextStartPos[1]] == 1)
                    {
                        return StartBFS(currentCount+1,nextStartPos, goalPos);
                    }
                }

                return 0;
            }

            private List<int[]> GetAroundTile(int[] pos)
            {
                List<int[]> ans = new List<int[]>();
                int[][] deltas = {  new int[2] { 0, 1 },
                                new int[2] { 1, 0 },
                                new int[2] { 0, -1 },
                                new int[2] { -1, 0 } };

                foreach (var delta in deltas)
                {
                    int[] newPos = { pos[0] + delta[0], pos[1] + delta[1] };
                    if (OnMap(newPos)) ans.Add(newPos);
                }
                return ans;
            }

            private bool OnMap(int[] pos)
            {
                if (pos[0] >= 0 && pos[0] < Map.Length)
                {
                    if (pos[1] >= 0 && pos[1] < Map[0].Length)
                    {
                        return true;
                    }
                }
                return false;
            }

            private int FindRoot(int[] goalPos)
            {
                Stack<int[]> root = new Stack<int[]>();
                root.Push(goalPos);

                TileFrom f = done.Find(i => i.ThisTile[0] == goalPos[0] && i.ThisTile[1] == goalPos[1]);
                while (true)
                {
                    root.Push(f.From);
                   // Console.WriteLine("[" + f.ThisTile[0] + "," + f.ThisTile[1] + "]" + "から[" + f.From[0] + "," + f.From[1] + "]");

                    TileFrom test = done.Find(i => i.ThisTile[0] == f.From[0] && i.ThisTile[1] == f.From[1]);

                    if (test.From == null) break;
                    f = test;
                }
                //while (root.Count > 0)
                //{
                //    int[] r = root.Pop();
                //    Console.WriteLine("[" + r[0] + "," + r[1] + "]");
                //}
                return root.Count - 1;
            }
        }


      

        static long Com(int n, int m)
        {
            if (m == 0 || m == n) return 1;

            if (n < m) return 0;

            int[] a = new int[m];

            for (int i = 0; i < m; i++)
            {
                a[i] = n - i;
            }
            for (int i = 1; i <= m; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (a[j] % i == 0)
                    {
                        a[j] /= i;
                        break;
                    }
                }
            }

            long ans = 1;
            for (int i = 0; i < m; i++)
            {
                ans *= a[i];
                ans %= mod;
            }
            return ans;
        }


        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        /// <summary>
        /// 最大公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }


        private static bool S(int[] data,int K ,int l ,int x)
        {
            int sum = 0;
            int max = Math.Min(x+1, data.Length);
            for (int i = l; i < max; i++)
            {
                sum += data[i];
            }
            Console.WriteLine(sum);
            return sum>=K;
        }


        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
        {
            if (items.Count() == 1)
            {
                yield return new T[] { items.First() };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };
                var unused = items.Except(leftside);
                foreach (var rightside in Enumerate(unused))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
        private static string ReplaceOneChar(string S, int index, string newS)
        {
            string s1 = S.Substring(0, index);
            string s2 = S.Substring(index + 1);
            return s1 + newS + s2;
        }

        private static bool PartialSum(int target, int[] Ns)
        {
            //if (target == 0) return true;
            bool[][] ps = new bool[Ns.Length + 1][];

            //i=0では、どんなWに対してもfalse
            ps[0] = new bool[target+1];
            for (int i = 0; i < ps[0].Length; i++) ps[0][i] = false;

            ps[0][0] = true;


            //考慮に入れるitemを、前から順に追加していく
            for (int i = 0; i < Ns.Length; i++)
            {
                //初期化
                ps[i + 1] = new bool[target+1];

                for (int t = 0; t <= target; t++)
                {
                    if (t >= Ns[i]) ps[i + 1][t] = ps[i][t - Ns[i]] || ps[i][t];
                    else ps[i + 1][t]=ps[i][t];
                }
            }

            return ps[Ns.Length][target];
        }

        /// <summary>
        /// 引数は、W(重さ制限)、items[重さ][価値]
        /// </summary>
        /// <param name="W"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        private static int DP(int W,int[][] items)
        {
            //データ
            int[][] dp = new int[items.Length+1][];

            //i=0では、どんなWに対しても0
            dp[0] = new int[W + 1];

            //考慮に入れるitemを、前から順に追加していく
            for (int i = 0; i < items.Length; i++)
            {
                //初期化
                dp[i+1] = new int[W + 1];

                for (int w = 0; w <= W; w++)
                {
                    if (w >= items[i][0]) dp[i + 1][w] = Math.Max(dp[i][w - items[i][0]]+items[i][1], dp[i][w]);
                    else dp[i + 1][w] = dp[i][w];
                }
            }
            return dp[items.Length][W];
        }

        private static long[] Read(string input)
        {
            string[] strings = input.Split(' ');
            long num = strings.Length;
            long[] ints = new long[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = long.Parse(strings[i]);
            }

            
            return ints;
        }
    }




    public static class FastIO
    {
        static System.IO.Stream str = System.Console.OpenStandardInput();
        const int size = 1024;
        static byte[] buffer = new byte[size];
        static int ptr;
        static int len;


        static byte Read()
        {
            if (ptr == len)
            {
                len = str.Read(buffer, 0, size);
                if (len == 0) return 0;
                ptr = 0;
            }
            return buffer[ptr++];
        }

        public static int Int()
        {
            var c = Read();
            while (c < 0x21)
            {
                c = Read();
            }
            var n = false;
            if (c == '-')
            {
                n = true;
                c = Read();
            }
            var ret = 0;
            while (c > 0x20)
            {
                ret = ret * 10 + c - '0';
                c = Read();
            }
            return n ? -ret : ret;
        }

        public static long Long()
        {
            var c = Read();
            while (c < 0x21)
            {
                c = Read();
            }
            var n = false;
            if (c == '-')
            {
                n = true;
                c = Read();
            }
            var ret = 0L;
            while (c > 0x20)
            {
                ret = ret * 10 + c - '0';
                c = Read();
            }
            return n ? -ret : ret;
        }
    }


    public class UnionFind
    {
        public UnionFind(int number)
        {
            Data = new List<int>();
            for (int i = 0; i < number; i++) Data.Add(-1);
        }

        /// <summary>
        /// 負なら親(絶対値はサイズ)　正なら子(絶対値は親のID)
        /// </summary>
        public List<int> Data { get; }

        public int Find(int node)
        {
            //自身が親なら、そのまま返す
            if (Data[node] < 0) return node;

            //子なら、その親を呼び、さらにその親を探す。再帰的に呼び出しrootを見つけ、全ての子の親をrootにする
            return Data[node] = Find(Data[node]);
        }

        public bool Unite(int node1, int node2)
        {
            //二つの点の親をさがす
            node1 = Find(node1);
            node2 = Find(node2);

            //二つの親が一致しているなら、することはない
            if (node1 == node2) return false;

            int parent = 0;
            int newSon = 0;

            //サイズが小さいほうが、大きい方の子になる(親のDataの値は負であることに注意)
            if (Data[node1] > Data[node2])
            {
                parent = node2;
                newSon = node1;
            }
            else
            {
                parent = node1;
                newSon = node2;
            }

            Data[parent] += Data[newSon];
            Data[newSon] = parent;

            return true;
        }
    }


    public class Tree
    {
        public class Node
        {
            public int? Parent = null;
            public List<int[]> Children = new List<int[]>();
            public int ParentColor = -1;
        }

        public Tree(int nodeNumber)
        {
            Nodes = new Node[nodeNumber];
            for (int i = 0; i < Nodes.Length; i++)
            {
                Nodes[i] = new Node();
                Connenters = new List<int[]>();

            }
        }

        /// <summary>
        /// 頂点の配列。それぞれの頂点には、一つの親と、複数の子がある
        /// </summary>
        public Node[] Nodes { get; }

        public List<int[]> Connenters { get; }

        public void Connent(int to, int from, int id = -1)
        {
            Connenters.Add(new int[3] { to, from, 0 });
            Nodes[to].Children.Add(new int[2] { from, id });
            Nodes[from].Parent = to;
        }


    }


}


Measured memory_bytes: 13140