#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(char a,char b)
{
return a>b;
}
int main()
{
string s,t;
cin>>s>>t;
sort(s.begin(),s.end());
sort(t.begin(),t.end(),cmp);
if(s<t)
cout<<"Yes";
else
cout<<"No";
return 0;
}