"use strict"

function main(input) {
  // S < T

  input = input.split(/\n/)
  let S = input[0].split("").sort()
  let T = input[1].split("").sort((a, b) => b.charCodeAt() - a.charCodeAt())
  const n = Math.min(S.length, T.length)
  let ans = "No"

  if (S.join("") == T.join("").substring(0, S.length) && S.length < T.length)
    ans = "Yes"
  else {
    for (let i = 0; i < n; i++) {
      //   console.log(S[i].charCodeAt(), T[i].charCodeAt())
      if (S[i].charCodeAt() < T[i].charCodeAt()) {
        ans = "Yes"
      }
    }
  }
  //   console.log(S.join(""), S, T)
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))