using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Magatro { static int N, K; static List Prime = new List(),hash=new List(); static bool[] flag = new bool[10]; static void Main() { Read(); Primecnt(); Hashcalc(); int migi = 0; int hidari = 0; int max=0; int first = 0; for (int i = 0; i < Prime.Count; i++) { if (!flag[hash[i]]) { migi++; flag[hash[i]] = true; } else { if (migi - hidari + 1 >= max) { max = migi - hidari + 1; first = hidari; } for (int j = hidari; hash[i] != hash[j]; j++) { hidari++; flag[hash[j]] = false; } hidari++; migi++; // flag[hash[i]] = false; } } if (migi - hidari + 1 >= max) { max = migi - hidari + 1; first = hidari; } Console.WriteLine(Prime[first]); } static void Hashcalc() { for(int i = 0; i true).ToArray(); n[0] = false; n[1] = false; int rootN = (int)Math.Sqrt(N) + 1; for (int i = 2; i <= rootN; i++) { if (n[i]) { for (int j = i + i; j <= N; j += i) { n[j] = false; } } } for (int i = K; i <= N; i++) { if (n[i]) { Prime.Add(i); } } } static void Read() { K = int.Parse(Console.ReadLine()); N = int.Parse(Console.ReadLine()); } }