Imports System.Collections.Generic
Imports System.Console
Imports System.Math  
Module Program
    Function divisor(n As Integer) As List(Of Integer)
        Dim res As New List(Of Integer)
        Dim sqrtN As Integer = Math.Sqrt(n)+2
        For i As Integer = 1 To sqrtN
            If (n Mod i) = 0 Then
                res.Add(i)
                If n / i <> i Then
                    res.Add(n / i)
                End If
            End If
        Next
        Return res
    End Function

 	Sub Main()
        Dim input() As String = Console.ReadLine().Split(" ")
        Dim N As Integer = input(0)
        Dim M As Integer  = input(1)
        Dim maxd As Integer = 0
        For Each d As Integer in divisor(M)
            If M / d >= N Then
                maxd = Math.Max(maxd, d)
            End If
        Next
        Console.WriteLine(maxd)
    End Sub
End Module
