You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
# -*- coding: utf-8 -*-
import sys
#s,t = map(list, input().split())
s = list(input())
t = list(input())

if len(s) < len(t):
    t2 = t.copy()
    for l in s:
        if l in t2:
            del t2[t2.index(l)]
        else:
            break
    else:
        print('yes')
        sys.exit()

s.sort()
t.sort()

if s[0] < t[-1]:
    print ('yes')
    sys.exit()
    
print('no')

# -*- coding: utf-8 -*-
import sys
#s,t = map(list, input().split())
s = list(input())
t = list(input())

if len(s) < len(t):
    t2 = t.copy()
    for l in s:
        if l in t2:
            del t2[t2.index(l)]
        else:
            break
    else:
        print('Yes')
        sys.exit()

s.sort()
t.sort()

if s[0] < t[-1]:
    print ('Yes')
    sys.exit()
    
print('No')
