import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== // 単純な素因数分解 Map dec(long n){ // 割った数を保存するマップ 3で2回割れたら、ans.get(3) == 2 となる Map ans = new HashMap(); long num = n; Long wk = 0L; // 2 ~ ルートn の間、繰り返す for(long i = 2; i * i <= n && num != 1; ++i){ // i で割り切れる間、割る while(num % i == 0){ num /= i; wk = ans.get(i); if(wk == null) { ans.put(i, 1L); } else { ans.replace(i, (wk+1L)); } } } if(num != 1) { wk = ans.get(num);// 最後に残った数も含める if(wk == null) { ans.put(num, 1L); } else { ans.replace(num, (wk+1L)); } } return ans; } Map> DEC = new HashMap<>(); public void solve() { long N = Integer.parseInt(sc.next()); int K = Integer.parseInt(sc.next()); for (long i = 1; i <= N; i++) { DEC.put(i, dec(i)); } long cnt, max = -1, ans = -1, wk; for (long i = 1; i < N; i++) { if(DEC.get(i) == null) continue; cnt = 0; for (long key : DEC.get(N).keySet()) { if(DEC.get(i).get(key) == null) continue; // out.println(" i = " + i + " key = " + key + " min(" // + DEC.get(i).get(key) + ", " + DEC.get(N).get(key) + ")"); cnt += Math.min(DEC.get(i).get(key), DEC.get(N).get(key)); } // out.println("[" + i + "] の共通の素因数の数 = " + cnt); if(cnt < K) continue; wk = 1; for (long key : DEC.get(i).keySet()) { wk *= (DEC.get(i).get(key) + 1); } // out.println("[" + i + "] の約数の数 = " + wk); if(max < wk) { max = wk; ans = i; } } out.println(ans); } // ================================================================== }