program main
  implicit none
  character(100) :: s, t
  read(*, *) s, t
  if (sorted(trim(s), .false.) <sorted(trim(t), .true.)) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
  contains

  function sorted(s, reverse)
    implicit none
    character(*), intent(in) :: s
    logical, intent(in) :: reverse
    character(len(s)) :: sorted
    integer :: i, j
    sorted = s
    do i = 2, len(s)  ! [1, i] の範囲を昇順に保つ
      do j = i, 2, -1
        if (sorted(j:j) < sorted(j - 1:j - 1) .neqv. reverse) then
          call swap(sorted(j:j), sorted(j - 1:j - 1))
        else
          exit
        end if
      end do
    end do
  end function sorted

  subroutine swap(x, y)
    implicit none
    character(1), intent(inout) :: x, y
    character(1) :: tmp
    tmp = x
    x = y
    y = tmp
  end subroutine swap
end program main
