Module Module1

    Sub Main()

        Dim N As Long
        Dim M As Long

        Dim sLine As String
        sLine = Console.ReadLine()
        Dim sSplitLine() As String
        sSplitLine = Split(sLine, " ")
        N = CLng(sSplitLine(0))
        M = CLng(sSplitLine(1))

        Dim nAnswer As Long
        If M Mod 2 = 1 Then
            M = (M - 1) / 2
        Else
            M = M / 2
        End If

        If N > M Then
            nAnswer = M
        Else
            nAnswer = N + CLng(((M - N) - 1) / 2)
        End If

        Console.WriteLine(nAnswer)




    End Sub

End Module
