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
    character(1) :: tmp
    integer :: i, j
    sorted = s
    do i = 2, len(s)
      do j = 1, i - 1
        if (sorted(i:i) < sorted(j:j) .neqv. reverse) then
          tmp = sorted(i:i)
          sorted(i:i) = sorted(j:j)
          sorted(j:j) = tmp
        end if
      end do
    end do
  end function sorted
end program main
