fun main(args:Array<String>) {
  val (head, tail) = (1..2).map {
    readLine()!!.toList()
  }
  val headSort = head.sorted().joinToString("")
  val tailRSort = tail.sorted().reversed().joinToString("")
  if( headSort < tailRSort )
    println("Yes")
  else
    println("No")
}