# -*- coding: utf-8 -*-



# AtCoder Beginner Contest

# Problem B





if __name__ == '__main__':

    s = sorted(list(eval(input())))

    t = sorted(list(eval(input())), reverse=True)



    if s < t:

        print('Yes')

    else:

        print('No')

# -*- coding: utf-8 -*-





def main():

    s = sorted(eval(input()))

    t = sorted(eval(input()), reverse=True)



    if s < t:

        print('Yes')

    else:

        print('No')





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
if __name__ == "__main__":
    s = sorted(list(eval(input())))
    t = sorted(list(eval(input())), reverse=True)
    if s < t:
        print("Yes")
    else:
        print("No")

# -*- coding: utf-8 -*-
def main():
    s = sorted(eval(input()))
    t = sorted(eval(input()), reverse=True)
    if s < t:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

-# AtCoder Beginner Contest -# Problem B -if __name__ == "__main__": -    s = sorted(list(eval(input()))) -    t = sorted(list(eval(input())), reverse=True) +def main(): +    s = sorted(eval(input())) +    t = sorted(eval(input()), reverse=True) + + +if __name__ == "__main__": +    main()