#include<bits/stdc++.h>

using namespace std;
bool cmp(char a,char b)
{
    return a>b;
}
int main()
{
    string s,t;cin>>s>>t;
    string tmps=s,tmpt=t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),cmp);
    if(s<t)
    {
        cout<<"Yes"<<endl;

    }
    else
    {
        cout<<"No"<<endl;
    }
}
