#include <iostream>

int main() {
	int N, M;
	std::cin >> N >> M;
	int gcd = M / N;
	for (; gcd > 1&&M%gcd; --gcd) {
		if (M > gcd*N) {
			if ((M - gcd * N) % gcd == 0)break;
		}
	}
	printf("%d", gcd);
}