function Main(input){
  input = input.split("\n");
  var s = input[0].split('');
  var t = input[1].split('');
  s.sort((a,b)=>a>b);
  t.sort((a,b)=>a<b);
  if(s[0]<t[0]){
    console.log('Yes');
  }else if(s[0]==t[0]){
    evenCheck(1);
  }else{
    console.log('No');
  }
  function evenCheck(n){
    if(s[n]<t[n]){
      console.log('Yes');
      return;
    }else if(s[n]>t[n]){
      console.log('No');
      return;
    }
    if((s.length-1==n)&&(t.length-1==n)){
      console.log('No');
      return;
    }else if(s.length-1==n){
      if(s.length<t.length){
        console.log('Yes');
        return;
      }
    }else if(t.length-1==n){
      if(s.length>t.length){
        console.log('No');
        return;
      }
    }
    if(s[n]==t[n]){
      n++;
      return evenCheck(n);
    }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));