'use strict'

function main(input) {
  input = input.split('\n')
  const a = input[0]
    .split('')
    .sort()
    .join('')
  const b = input[1]
    .split('')
    .sort()
    .reverse()
    .join('')
  if (a === b) {
    console.log('No')
    return
  }
  const dic = [a, b].sort()

  if (a === div[0]) console.log('Yes')
  else console.log('No')
}
main(
  require('fs')
    .readFileSync('/dev/stdin', 'utf8')
    .trim()
)