local a = io.read()
local b = io.read()
local at, bt = {}, {}
for i = 1, #a do at[i] = a:sub(i, i) end
for i = 1, #b do bt[i] = b:sub(i, i) end
table.sort(at)
table.sort(bt, function(x, y) return x > y end)
a = ""
for i = 1, #at do a = a .. at[i] end
b = ""
for i = 1, #bt do b = b .. bt[i] end
print(a < b and "Yes" or "No")
