integer::R1(97:122)=-1,R2(97:122)=-1
character(2*10**5) S,T
logical check
read*,S
read*,T

check=.true.
do i=1,len_trim(S)
  if(R1( ichar(S(i:i)) )==-1)then
    R1( ichar(S(i:i)) )=ichar(T(i:i))
  else
    if(R1( ichar(S(i:i)) )/=ichar(T(i:i)))check=.false.
  endif
  if(R2( ichar(T(i:i)) )==-1)then
    R2( ichar(T(i:i)) )=ichar(S(i:i))
  else
    if(R2( ichar(T(i:i)) )/=ichar(S(i:i)))check=.false.
  endif
end do

if(check)then
  print"(A)","Yes"
else
  print"(A)","No"
endif

end