#include <iostream>

int main() {
  long N, M;
  std::cin >> N >> M;

  long r;
  for (r = M / N; r > 0; r--) {
    if (M % r == 0) {
      break;
    }
  }

  std::cout << r << std::endl;
  return 0;
}