#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	getline(cin,a);
	getline(cin,b);
	sort(b.begin(),b.end(),greater<char>()); 
    sort(a.begin(),a.end());
	if(a<b)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
}
