#28 B - Two Anagrams

s = list(eval(input()))

t = list(eval(input()))



s = sorted(s,reverse = False)

t = sorted(t,reverse = True)



result = 'No'

rang = min(len(s),len(t))

for i in range(rang):

    if ord(s[i]) < ord(t[i]):

        result = 'Yes'

        break

else:

    # 文字が一緒で t の方が文字数が多いとき

    if (s[:rang] == t[:rang]) and len(s) < len(t):

        result = 'Yes'

print(result)
#28 B - Two Anagrams AC

s = list(eval(input()))

t = list(eval(input()))



s = sorted(s,reverse = False)

t = sorted(t,reverse = True)



s = ''.join(s)

t = ''.join(t)

if s < t:

    print('Yes')

else:

    print('No')
# 28 B - Two Anagrams
s = list(eval(input()))
t = list(eval(input()))
s = sorted(s, reverse=False)
t = sorted(t, reverse=True)
result = "No"
rang = min(len(s), len(t))
for i in range(rang):
    if ord(s[i]) < ord(t[i]):
        result = "Yes"
        break
else:
    # 文字が一緒で t の方が文字数が多いとき
    if (s[:rang] == t[:rang]) and len(s) < len(t):
        result = "Yes"
print(result)

# 28 B - Two Anagrams AC
s = list(eval(input()))
t = list(eval(input()))
s = sorted(s, reverse=False)
t = sorted(t, reverse=True)
s = "".join(s)
t = "".join(t)
if s < t:
    print("Yes")
else:
    print("No")

-# 28 B - Two Anagrams +# 28 B - Two Anagrams AC -result = "No" -rang = min(len(s), len(t)) -for i in range(rang): -    if ord(s[i]) < ord(t[i]): -        result = "Yes" -        break +s = "".join(s) +t = "".join(t) +if s < t: +    print("Yes") -    # 文字が一緒で t の方が文字数が多いとき -    if (s[:rang] == t[:rang]) and len(s) < len(t): -        result = "Yes" -print(result) +    print("No")