using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; long num = long.Parse(Reader.ReadLine()); Dictionary tmp = this.CreateDic(num); long ans = num; if(tmp.ContainsKey(2) && tmp[2] >= 2) { ans = 4; } ans = Math.Min(ans, tmp.Keys.Where(a=>a>2).Min()); Console.WriteLine(ans); } private Dictionary CreateDic(long num) { long tmp = num; Dictionary ret = new Dictionary(); for(long i=2; i*i<=num; i++) { while (tmp % i == 0) { if(ret.ContainsKey(i)) { ret[i]++; } else { ret.Add(i, 1); } if(i > 2) { return ret; } tmp = tmp / i; } if(tmp == 1) { break; } } if(tmp > 1) { ret.Add(tmp, 1); } return ret; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 999999999989 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }