local s=io.read()
local t=io.read()

sanagram={}
tanagram={}
for i=1,#s do
    table.insert(sanagram,s:sub(i,i))
end
for i=1,#t do
    table.insert(tanagram,t:sub(i,i))
end
table.sort(sanagram)
table.sort(tanagram,function(a,b)
    return a>b
end)

if table.concat(sanagram,"")<table.concat(tanagram,"") then
    print("Yes")
else
    print("No")
end