//
//  main.cpp
//  contest
//
//  Created by S M HEMEL on 27/1/18.
//  Copyright © 2018 Eastern University. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s,s1;
    while(cin >> s >> s1){
        int la=(int)s.size();
        int lb=(int)s1.size();
        sort(s.begin(),s.end());
        sort(s1.begin(),s1.end());
        if(s[0]<s1[lb-1]) return 0 * puts("Yes");
        else if(s[0]>s1[lb-1]) return 0 * puts("Yes");
        else{
            if(s[0]==s[la-1]&&s1[0]==s1[lb-1]&&s[0]==s1[0]){
                if(lb>la) return 0 * puts("Yes");
                else return 0 * puts("No");
            }
            int k=0;
            for(int i=0;i<la;i++){
                for(int j=0;j<lb;j++){
                    if(s1[j]>s[i]){
                        k++;
                        break;
                    }
                }
            }
            if(k==la) puts("Yes");
            else puts("No");
        }
    }
    return 0;
    
}
