#include <bits/stdc++.h>
using namespace std;
#define valid(nx,mx,n,m) nx>=0&&nx<n&&mx>=0&&mx<m
#define vvalid(nx,mx,n,m) nx>=1&&nx<=n&&mx>=1&&mx<=m
#define mem(a,b)      memset(a, b, sizeof (a))
#define pb            push_back
#define mp            make_pair
#define sz            size()
#define kohli         0
#define ll            long long
#define si(x)         scanf("%lld",&x)
#define vsort(v)      sort(v.begin(),v.end())
#define usort(x,n)    sort(x,x+n,greater<int>())
#define nl            printf("\n")
#define pi(x)         printf("%d",x)
#define ps(ch)        printf("%s",ch)
#define pll(x)        printf("%lld",x)
#define gcd(a,b)      __gcd(a,b)
#define lcm(a,b)      (a*(b/gcd(a,b)))
//#define mod           1000003
#define sp            printf(" ")
#define Pi            acos(-1)
#define inf           229496729
#define F(i,a,b)      for(i=a;i<=b;i++)
#define f(i,a,b)      for(i=a;i<b;i++)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))
#define distance( x1 ,y1 ,x2 ,y2 )    sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) )
#define mx 1000060

int setb(int n,int pos)
{
    return n=n | (1 << pos);
}
int resb(int n,int pos)
{
    return n=n & ~(1 << pos);
}
bool checkb(int n,int pos)
{
    return (bool)(n & (1 << pos));
}

typedef pair<double,double> pr;
const double eps = 1e-9;
bool isequal(double x, double y)
{
    if(abs((x-y)/y)<0.000001)
        return true;
    return 0;
}
///(lower_bound(cst,cst+(n-1),x)-cst)
//int dx[] = {+0,+1,+0,-1};
//int dy[] = {+1,+0,-1,+0};
//int dx[] = {-1,-1,-1,+0,+0,+1,+1,+1};
//int dy[] = {-1,+0,+1,-1,+1,-1,+0,+1};
////int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2}; //knight moves
////int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1}; //knight moves
//
//struct segment
//{
//	int u;
//	int v;
//} seg[100030];
//
//bool structCompare(segment first,segment second)
//{
//    if(first.u != second.u)
//        return first.u<second.u;  ///first onujaye kre. jodi first
//    else							///same hoe jae tkn second onujaye kre
//        return first.v > second.v;
//}
//int ara[] = {1, 5, 10, 25, 50};
//
//int findd(int n)
//{
//    if(ara[n]==n)
//        return n;
//    return ara[n] = findd(ara[n]);
//}
//
//struct edge
//{
//    int u,v,w;
//    bool operator<(const edge &p) const
//    {
//        return w < p.w;
//    }
//};


int BIT[100050], a[100050], n;
void update(int x, int delta)
{
      for(; x <= n; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
     int sum = 0;
     for(; x > 0; x -= x&-x)
        sum += BIT[x];
     return sum;
}
bool prime[mx+5];
int aaa[mx+5];


void sieve()
{
	int i,j;
	prime[1] = true;
	for(i=4;i<=mx;i+=2)
		prime[i] = true;
	int w = sqrt(mx);
	for(i=3;i<=w;i+=2)
	{
		if(!prime[i])
		{
			for(j=i*i;j<=mx;j+=2*i)
				prime[j] = true;
		}
	}
	int x = 1;
	for(i=1;i<=mx;i++)
	{
		if(!prime[i])
			aaa[i] = x++;
		else
			aaa[i] = x-1;
	}
//	for(i=1;i<=100;i++)
//		pi(aaa[i]),sp;
//	nl;
}

int main()
{
//	mem(prime, false);
//	sieve();
//    bitwise();
//    totient();
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    ios_base::synnc_with_stdio(false); cin.tie(NuLL);
	char ch[100010],chh[100010];
	int i,j;
	string cc,ccc;
	while(scanf("%s %s",ch,chh)==2)
	{
		int l = strlen(ch);
		int l2 = strlen(chh);
		sort(ch,ch+l);
		sort(chh,chh+l2);
		for(i=0,j=l2-1;i<j;i++,j--)
		{
			swap(chh[i],chh[j]);
		}
		for(i=0;i<l;i++)
			cc+=ch[i];
		for(i=0;i<l2;i++)
			ccc+=chh[i];
		//printf("%s %s\n",ch,chh);
		if(cc<ccc)
			printf("Yes\n");
		else
			printf("No\n");
		cc.clear();
		ccc.clear();
	}
    return 0;
}



Measured memory_bytes: 256