
Module Module1

    Sub main()
        'Dim str1 As String = "cd"
        'Dim str2 As String = "abc"

        Dim str1 = Console.ReadLine()
        Dim str2 = Console.ReadLine()


        Dim parts1 As New List(Of Char), parts2 As New List(Of Char)
        parts1 = New List(Of Char)(str1.ToCharArray)
        parts2 = New List(Of Char)(str2.ToCharArray)

        parts1.Sort()
        parts2.Sort()
        parts1.Reverse()
        parts2.Reverse()

        Dim result As String = "No"
        If String.Join("", parts1.ToArray) < String.Join("", parts2.ToArray) Then
            result = "Yes"

        End If
        Console.WriteLine(result)

    End Sub
end module