program prob5
    implicit none
    integer, parameter :: N = 200005
    character(N) :: s, t
    integer :: a(26), b(26), c(26)
    integer :: i, L, j
    read(*,*) s, t
    
    L = len_trim(S)
    do i = 1, 26
        a(i) = 26
    end do

    do i = 1, L
        if(a(ichar(s(i:i)) - ichar('a') + 1) == 26) then
            a(ichar(s(i:i)) - ichar('a') + 1) = ichar(t(i:i)) - ichar('a')
        else
            if(a(ichar(s(i:i)) - ichar('a') + 1) == ichar(t(i:i)) - ichar('a')) then
                cycle
            else
                write(*,*) 'No'
                stop
            end if
        end if
    end do

    do i = 1, 26
        do j = 1, 26
            if(i == j) then
                cycle
            end if
            if(a(i) == 26) then
                cycle
            end if
            if(a(i) == a(j)) then
                write(*,*) 'No'
                stop
            end if
        end do
    end do
    ! b = 0
    ! c = 0
    ! do i = 1, L
    !     b(ichar(s(i:i)) - ichar('a') + 1) = 1
    !     c(ichar(t(i:i)) - ichar('a') + 1) = 1
    ! end do
    ! do i = 1, 26
    !     if(b(i) /= c(i)) then
    !         write(*,*) 'No'
    !         stop
    !     end if
    ! end do

    write(*,*) 'Yes'

    stop
contains
end program prob5