Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = NextString()
        Dim t As String = NextString()

        Dim arrS As Char() = String2CharArr(s)
        Dim arrT As Char() = String2CharArr(t)

        Array.Sort(arrS)

        Array.Sort(arrT)
        Array.Reverse(arrT)

        For i As Integer = 0 To Math.Min(arrS.Length, arrT.Length) - 1
            If arrS(i) < arrT(i) Then
                WriteLine("Yes")
                Exit Sub
            End If
        Next

        If arrS.Length < arrT.Length Then
            WriteLine("Yes")
        Else
            WriteLine("No")
        End If

    End Sub

    Function String2CharArr(s As String) As Char()
        Dim result As Char() = New Char(s.Length - 1) {}
        Dim i As Integer = 0
        For Each c As Char In s
            result(i) = c
            i += 1
        Next
        Return result
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
