program string_transformation
  implicit none
  character(200000) :: s, t
  integer :: n, i, j, a, b
  logical :: x(26,26) = .false.
  read(*,*) s
  read(*,*) t
  n = len_trim(s)
  do i = 1, n
    x(ord(s(i:i)),ord(t(i:i))) = .true.
  end do
  do i = 1, 26
    a = 0
    b = 0
    do j = 1, 26
      if (x(i,j)) a = a+1
      if (x(j,i)) b = b+1
    end do
    if (a > 1 .or. b > 1) then
      write(*,'(a)') "No"
      stop
    end if
  end do
  write(*,'(a)') "Yes"
contains
  integer function ord(s)
    character(1), intent(in) :: s
    ord = ichar(s)-96
  end
end program string_transformation