program partition
  implicit none
  integer(8) :: n, m, i, d0, d1
  read(*,*) n, m
  d0 = 1
  do
     d1 = minimum_divisor(m,d0)
     if (n*d1 .gt. m) exit
     d0 = d1
  end do
  write(*,'(i0)') d0 
  stop
contains
  function minimum_divisor(b,idx) result(d)
    implicit none
    integer(8), intent(in) :: b, idx
    integer(8)             :: d, i
    do i = idx+1, b
       if (mod(b,i) .eq. 0) then
          d = i
          exit
       end if
    end do
    return
  end function minimum_divisor
end program partition