#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string s,t;
	
	cin>>s>>t;
	int i,sl=s.length();
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	if(s<t)
	{
		cout<<"Yes"<<endl;
		return 0;
		
	}
	else cout<<"No"<<endl;
	
}
