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

int main(){
char a[1000],b[1000],a1[1000],b1[1000],r='a';
int c,k,w;
gets(a);
gets(b);
 
 for (int i = 0; i < strlen(b); i++){//字母排序     摘抄 
		for (int j = i + 1; j < strlen(b); j++){
			if (b[j] > b[i]){
				char pTem = b[j];
				b[j] = b[i];
				b[i] = pTem;
			}
		}
	}
for (int i = 0; i < strlen(a); i++){//字母排序     摘抄 
		for (int j = i + 1; j < strlen(a); j++){
			if (a[j] < a[i]){
				char pTem = a[j];
				a[j] = a[i];
				a[i] = pTem;
			}
		}
	}
cout<<a<<endl<<b<<endl;
for(int i=0;i<=500;i++){
	if(a[i]<b[i]){
cout<<"Yes"; 

	return 0;
}	 



if(a[i]>b[i]){
	cout<<"no";
	
	return 0;
}