#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def s(n):\n"
"    return[m(t)for t in d(f(n))]\n"
"def f(n):\n"
"    l=[]\n"
"    b,e=2,0\n"
"    while b*b<=n:\n"
"        while not n%b:\n"
"            n//=b\n"
"            e+=1\n"
"        if e:\n"
"            l.append((b,e))\n"
"        b,e=b+1,0\n"
"    if n>1:\n"
"        l.append((n,1))\n"
"    return l\n"
"def d(l):\n"
"    b,e=l.pop()\n"
"    p=d(l)if l else[[]]\n"
"    v=[[(b,k)]for k in range(e+1)]\n"
"    return[s+t for s in p for t in v]\n"
"def m(l):\n"
"    a=1\n"
"    for b,e in l:\n"
"        a*=b**e\n"
"    return a\n"
"N,M=map(int,input().split())\n"
"if M<2:print(1);exit()\n"
"a=0\n"
"for i in sorted(s(M))[::-1]:\n"
"    if M//i>=N:\n"
"        a=i\n"
"        break\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            