import sys

import math

import itertools

import bisect

from copy import copy

from collections import deque,Counter

from decimal import Decimal

def s(): return eval(input())

def i(): return int(eval(input()))

def S(): return input().split()

def I(): return list(map(int,input().split()))

def X(): return list(eval(input()))

def L(): return list(input().split())

def l(): return list(map(int,input().split()))

def lcm(a,b): return a*b//math.gcd(a,b)

sys.setrecursionlimit(10 ** 9)

mod = 10**9+7



s = X()

t = X()



s.sort()

t.sort()

t.reverse()



a = "".join(s)

b = "".join(t)



if a < b:

    print("Yes")

else:

    print("No")

import sys

import math

import itertools

import bisect

from copy import copy

from collections import deque,Counter

from decimal import Decimal
from functools import reduce

def s(): return eval(input())

def i(): return int(eval(input()))

def S(): return input().split()

def I(): return list(map(int,input().split()))

def X(): return list(eval(input()))

def L(): return list(input().split())

def l(): return list(map(int,input().split()))

def lcm(a,b): return a*b//math.gcd(a,b)

def gcd(*numbers): reduce(math.gcd, numbers)

sys.setrecursionlimit(10 ** 9)

mod = 10**9+7

count = 0

ans = 0



a = s()

t = s()



a = sorted(a)

y = "".join(a)

t = sorted(t,reverse = True)

x = "".join(t)

if y < x:

    print("Yes")

else:

    print("No")

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal


def s():
    return eval(input())


def i():
    return int(eval(input()))


def S():
    return input().split()


def I():
    return list(map(int, input().split()))


def X():
    return list(eval(input()))


def L():
    return list(input().split())


def l():
    return list(map(int, input().split()))


def lcm(a, b):
    return a * b // math.gcd(a, b)


sys.setrecursionlimit(10**9)
mod = 10**9 + 7
s = X()
t = X()
s.sort()
t.sort()
t.reverse()
a = "".join(s)
b = "".join(t)
if a < b:
    print("Yes")
else:
    print("No")

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
from functools import reduce


def s():
    return eval(input())


def i():
    return int(eval(input()))


def S():
    return input().split()


def I():
    return list(map(int, input().split()))


def X():
    return list(eval(input()))


def L():
    return list(input().split())


def l():
    return list(map(int, input().split()))


def lcm(a, b):
    return a * b // math.gcd(a, b)


def gcd(*numbers):
    reduce(math.gcd, numbers)


sys.setrecursionlimit(10**9)
mod = 10**9 + 7
count = 0
ans = 0
a = s()
t = s()
a = sorted(a)
y = "".join(a)
t = sorted(t, reverse=True)
x = "".join(t)
if y < x:
    print("Yes")
else:
    print("No")

+from functools import reduce +def gcd(*numbers): +    reduce(math.gcd, numbers) + + -s = X() -t = X() -s.sort() -t.sort() -t.reverse() -a = "".join(s) -b = "".join(t) -if a < b: +count = 0 +ans = 0 +a = s() +t = s() +a = sorted(a) +y = "".join(a) +t = sorted(t, reverse=True) +x = "".join(t) +if y < x: