function main(input) {
  input=input.trim();
  const s = input.split("\n")[0];
  const t = input.split("\n")[1];
  var arr1=[]
  var arr2=[]

  function narabi(n,arr){
    for(var i=0; i<n.length; i++){
      arr.push(n.substr(i,1))
    }
  }
  narabi(s,arr1)
  narabi(t,arr2)

  arr1.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  arr2.sort(function(a,b){
    if( a < b ) return 1;
    if( a > b ) return -1;
    return 0;
  });
  //console.log(arr1,arr2);

  if(arr1.join("")<arr2.join("")){
    console.log("Yes");
  }else{
    console.log("No");
  }
  
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));