s = list(eval(input()))

t = list(eval(input()))



s.sort()

t.sort(reverse=True)



if ''.join(s) < ''.join(t):

    print('Yes')

else:

    print('No')

def main():

    s = list(eval(input()))

    t = list(eval(input()))

    

    s.sort()

    t.sort(reverse=True)

    

    if ''.join(s) < ''.join(t):

        print('Yes')

    else:

        print('No')



if __name__ == '__main__':

    main()
s = list(eval(input()))
t = list(eval(input()))
s.sort()
t.sort(reverse=True)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

def main():
    s = list(eval(input()))
    t = list(eval(input()))
    s.sort()
    t.sort(reverse=True)
    if "".join(s) < "".join(t):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

-s = list(eval(input())) -t = list(eval(input())) -s.sort() -t.sort(reverse=True) -if "".join(s) < "".join(t): -    print("Yes") -else: -    print("No") +def main(): +    s = list(eval(input())) +    t = list(eval(input())) +    s.sort() +    t.sort(reverse=True) +    if "".join(s) < "".join(t): +        print("Yes") +    else: +        print("No") + + +if __name__ == "__main__": +    main()