import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()

    (if (judge(calc(s), calc(t).reversed())) "Yes" else "No")
            .let(::println)
}

fun calc(s: String): List<Char> {
    return s.toCharArray().sorted()
}

fun judge(s: List<Char>, t: List<Char>): Boolean {
    for (i in 0 until Math.max(s.size, t.size)) {
        if (i >= s.size) {
            return true
        }
        if (i >= t.size) {
            return false
        }
        if (s[i].toInt() < t[i].toInt()) {
            return true
        }
        if (s[i].toInt() > t[i].toInt()) {
            return false
        }
    }
    return false
}
