fun main(args: Array<String>) {

    val s = readLine()!!.toCharArray().sorted()
    val t = readLine()!!.toCharArray().sortedDescending()
    val sortedS = s.joinToString(separator = "")
    val sortedT = t.joinToString(separator = "")

    val result = if (sortedS < sortedT) "Yes" else "No"

    print(result)
}