#include<iostream>
using namespace std;

typedef long long ll;

int main() {
	ll N, M;
	cin >> N >> M;

	ll ans;
	for (int i = M/N; i > 0; i--) {
		if (M%i == 0 && i*N <= M) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

}