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