using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToInt();
            var ans = 0;
            for (int i = n; i <= 999999; i++)
            {
                if (IsPrime(i))
                {
                    ans = i;
                    break;
                }
            }
            WriteRead(ans);
        }

        public static bool IsPrime(int 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;
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        public static List<List<T>> Permutations<T>(List<T> src, int n)
        {
            // nは1以上かつsrcの長さよりも短い必要がある。
            int len = src.Count;
            if (!(0 < n && n <= len))
            {
                throw new ArgumentOutOfRangeException();
            }

            var permutations = new List<List<T>>();
            var queue = new Queue<List<int>>(Enumerable.Range(0, len).Select(i => new List<int>() { i }));
            while (queue.Any())
            {
                var indexes = queue.Dequeue();

                if (indexes.Count == n)
                {
                    permutations.Add(indexes.Select(index => src[index]).ToList());
                    continue;
                }

                for (int index = 0; index < len; index++)
                {
                    if (indexes.Contains(index))
                    {
                        continue;
                    }

                    var newIndexes = new List<int>(indexes);
                    newIndexes.Add(index);
                    queue.Enqueue(newIndexes);
                }
            }

            return permutations;
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 11092