#include <bits/stdc++.h>
using namespace std;

int main(){
	string a,b;
	cin >> a >> b;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<char>());
	if(a < b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}