#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i > M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;

typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}
template<class T>
T POW(T n, T m) {
	T res = 1;
	rep(i, 0, m) {
		res *= n;
	}
	return res;
}

ll power(ll x, ll y, ll mod) {
	if (y == 0)return 1;
	if (y == 1)return x % mod;
	if (y == 1)return x % mod;
	if (y % 2 == 0)return POW(power(x, y / 2, mod), 2LL) % mod;
	return ((POW(power(x, y / 2, mod), 2LL) % mod)*(x%mod)) % mod;
}
ll div(ll a, ll  b, ll mod) {
	return (a* power(b, mod - 2, mod)) % mod;
}

template<
	typename Inputs,
	typename Functor,
	typename T = typename Inputs::value_type>
	void sort_by(Inputs& inputs, Functor f) {
	std::sort(std::begin(inputs), std::end(inputs),
		[&f](const T& lhs, const T& rhs) { return f(lhs) < f(rhs); });
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;

ll MOD_NUM = POW(10LL, 9LL) + 7;

vector<pll >prime_factorize(ll n) {
	vector<pll> res;
	for (ll p = 2; p*p <= n; ++p) {
		if (n%p != 0)continue;
		ll num = 0;
		while (n%p == 0) { ++num; n /= p; }
		res.push_back({ p,num });
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

class Combination {
	// this calculates combination (nCk).
	// Constructor runs in O(MAX).
	// get(n,k) returns nCk in O(1).

	ll MAX, MOD;
	vll fac;
	vll finv;
	vll inv;
public:
	Combination(ll MAX = 210000LL, ll MOD = 1000000007LL)
		:MOD(MOD), MAX(MAX), fac(vll(MAX)), finv(vll(MAX)), inv(vll(MAX)) {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		rep(i, 2, MAX) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	ll get(ll n, ll k) {
		if (n < k)return 0;
		if (n < 0 || k < 0)return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
};

auto count(vll v) {
	vector<pll> res;
	rep(i, 1, POW(10, 5) + 1) {
		auto it = lower_bound(all(v), i);
		if (it != v.end()) {
			res.push_back({ i, distance(it, upper_bound(all(v), i)) });
		}
	}
	return res;
}

int main() {

	ll N, M;
	cin >> N >> M;
	auto v = prime_factorize(M);

	vll divs = { 1 };
	ll res=0;
	rep(i, 0, v.size()) {
		ll t = divs.size();
		 rep(j, 0, t) {
			 rep(k, 1, v[i].second + 1)
			{
				divs.push_back(divs[j]*POW(v[i].first,k));
			}
		}
		
	}
	sort(all(divs));
	rrep(i,  divs.size()-1,-1) {
		if (M / divs[i] >= N) {
			cout << divs[i];
			return 0;
		}
	}
	





}


Measured memory_bytes: 256