local s = io.read("*l")
local t = io.read("*l")

local s_bytes = {s:byte(1, s:len())}
local t_bytes = {t:byte(1, t:len())}
table.sort(s_bytes)
table.sort(t_bytes, function(x, y) return x > y end)

local diff_value = -1
for i = 1, math.min(#s_bytes, #t_bytes) do
    if s_bytes[i] ~= t_bytes[i] then
        diff_value = i
        break
    end
end

local is_yes = false
if diff_value == -1 then
    if #s_bytes < #t_bytes then
        is_yes = true
    end
else
    if s_bytes[diff_value] < t_bytes[diff_value] then
        is_yes = true
    end
end

print(is_yes and "Yes" or "No")