function main(input){
  var lines = input.split('\n');
  var s = lines[0].split(""); // change to array
  var t = lines[1].split("");
  s = s.sort();
  t = t.reverse();
//  console.log(s,t);
  for(i=0; i<Math.min(s.length,t.length); i++){
//    console.log(s[i], t[i]);
    if (t[i].localeCompare(s[i]) > 0) {  // -1 0 1
      return console.log('Yes');
    }
  }

  if (t[i-1]==s[i-1] && t.length>s.length){
    return console.log('Yes');
  }
  
  return console.log('No');

}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));