program sample
implicit none
character(len=2*10**5) :: x,y
integer(8) :: i,j,n,count1,count2
integer(8) :: a(26),b(26)

read(*,*) x
read(*,*) y

count1=0
count2=0

n=len_trim(x)

do i=1,n
	do j=i+1,n
		if (x(i:i) == x(j:j)) then
			if (ichar(y(i:i)) /= ichar(y(j:j))) then
            	count1= count1+1
            end if
        end if
    end do
end do

do i=1,n
	do j=i+1,n
		if (y(i:i) == y(j:j)) then
			if (ichar(x(i:i)) /= ichar(x(j:j))) then
            	count2= count2+1
            end if
        end if
    end do
end do

if(count1==0 .and. count2==0) then
write(*,*) 'Yes'
else
write(*,*) 'No'
end if

!write(*,*) ichar('a'),ichar('z'),count1,count2
!write(*,*) 

end program sample