program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,m,n,a,b
    integer(8) :: x(26),y(26)
  
    read(*,*) s
    read(*,*) t
    x(:)=0
    y(:)=0
    m=len_trim(s)
    n=len_trim(t)
    do i=1,m
        a=ichar(s(i:i))-96
        x(a)=x(a)+1
    end do
    do i=1,n
        a=ichar(t(i:i))-96
        y(a)=y(a)+1
    end do
    do i=1,26
        if(x(i)/=0)then
            a=i
            exit
        end if
    end do
    do i=26,1,-1
        if(y(i)/=0)then
            b=i
            exit
        end if
    end do
    
    if(a>b)then
        write(*,*)'No'
    else if(a<b)then
        write(*,*)'Yes'
    else if(x(a)/=m .or. y(b)/=n)then
        write(*,*)'No'
    elseif(n>m)then
        write(*,*)'Yes'
    elseif(n<=m)then
        write(*,*)'No'
    end if

  
    stop
end program sample
  

