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

int main()
{
    string n,m;

    cin>>n>>m;

    sort(n.begin(), n.end());
    sort(m.begin(), m.end(), greater<int>());


    if(n < m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;




}
