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 N > CLng(M / 2) Then
            nAnswer = CLng(M / 2)
        Else
            nAnswer = N + CLng((M - 2 * N) / 4)
        End If

        Console.WriteLine(nAnswer)




    End Sub

End Module
