"use strict";
    
// 約数列挙
const calcDivisor = N => {
  let result = [];

  for(let i=1; i*i<=N; i++) {
    if(N % i === 0) {
      result.push(i);
      const j = N / i;
      if(j !== i) result.push(j);
    }
  }

  return result.sort((a,b)=>a-b);
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const divides = calcDivisor(M);
    
    let answer = 1;
    
    for(let i=0; i<divides.length; i++) {
        if(N * divides[i] <= M) {
            answer = divides[i];
        } else {
            break;
        }
    }
    
    console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));