program prob4
    implicit none
    integer::N, i, ans, l, j, k
    character(len=200005)::S,T
    integer::c(26), d(26)
    read(*,*) S, T
    l = len_trim(S)
    c = 0
    d = 0

    do i = 1, l
        j = ichar(S(i:i)) - 96
        k = ichar(T(i:i)) - 96
        if(c(j) > 0) then
            if(k .ne. c(j)) then
                write(*,'(a)') "No"
                stop
            end if
        else
            c(j) = k
        end if
        if(d(k) > 0) then
            if(j .ne. d(k)) then
                write(*,'(a)') "No"
                stop
            end if
        else
            d(k) = j
        end if
    end do
    write(*,'(a)') "Yes"
    stop
end program