"""

import string

al = string.ascii_lowercase



ord('A') =65

chr(65) ='A'

"""





def c2i(c): return ord(c) - ord('a')





s = eval(input())

t = eval(input())



chrList = [-1 for _ in range(26)]



flg = True

for i in range(len(s)):

    idx_s = c2i(s[i])

    idx_t = c2i(t[i])



    if chrList[idx_s] == -1:

        chrList[idx_s] = idx_t

    else:

        if chrList[idx_s] != idx_t:

            flg = False

            break



# 変換先が重複していないことを調べる

# 変換先のインデックスchrList[i]に該当するchkをTrueにしていく

chk = [False for _ in range(26)]

for i in range(26):

    if chrList[i] == -1:

        pass

    elif not chk[chrList[i]]:

        chk[chrList[i]] = True

    else:

        flg = False

        break



print(('Yes' if flg else 'No'))

# print(sorted(list(map(chr, list(map(lambda x: x + ord('a'), chrList))))))
from string import ascii_lowercase



s = eval(input())

t = eval(input())



d_s2t = dict()

d_t2s = dict()



flg = True

for ss, tt in zip(s, t):

    if d_s2t.get(ss) is None:

        d_s2t[ss] = tt

    else:

        if not d_s2t[ss] == tt:

            flg = False

            break



    if d_t2s.get(tt) is None:

        d_t2s[tt] = ss

    else:

        if not d_t2s[tt] == ss:

            flg = False

            break



if flg:

    if len(set(d_s2t.keys())) != len(set(d_s2t.values())):

        flg = False

    if len(set(d_t2s.keys())) != len(set(d_t2s.values())):

        flg = False



print(('Yes' if flg else 'No'))

"""
import string
al = string.ascii_lowercase
ord('A') =65
chr(65) ='A'
"""


def c2i(c):
    return ord(c) - ord("a")


s = eval(input())
t = eval(input())
chrList = [-1 for _ in range(26)]
flg = True
for i in range(len(s)):
    idx_s = c2i(s[i])
    idx_t = c2i(t[i])
    if chrList[idx_s] == -1:
        chrList[idx_s] = idx_t
    else:
        if chrList[idx_s] != idx_t:
            flg = False
            break
# 変換先が重複していないことを調べる
# 変換先のインデックスchrList[i]に該当するchkをTrueにしていく
chk = [False for _ in range(26)]
for i in range(26):
    if chrList[i] == -1:
        pass
    elif not chk[chrList[i]]:
        chk[chrList[i]] = True
    else:
        flg = False
        break
print(("Yes" if flg else "No"))
# print(sorted(list(map(chr, list(map(lambda x: x + ord('a'), chrList))))))

from string import ascii_lowercase

s = eval(input())
t = eval(input())
d_s2t = dict()
d_t2s = dict()
flg = True
for ss, tt in zip(s, t):
    if d_s2t.get(ss) is None:
        d_s2t[ss] = tt
    else:
        if not d_s2t[ss] == tt:
            flg = False
            break
    if d_t2s.get(tt) is None:
        d_t2s[tt] = ss
    else:
        if not d_t2s[tt] == ss:
            flg = False
            break
if flg:
    if len(set(d_s2t.keys())) != len(set(d_s2t.values())):
        flg = False
    if len(set(d_t2s.keys())) != len(set(d_t2s.values())):
        flg = False
print(("Yes" if flg else "No"))

-""" -import string -al = string.ascii_lowercase -ord('A') =65 -chr(65) ='A' -""" - - -def c2i(c): -    return ord(c) - ord("a") - +from string import ascii_lowercase -chrList = [-1 for _ in range(26)] +d_s2t = dict() +d_t2s = dict() -for i in range(len(s)): -    idx_s = c2i(s[i]) -    idx_t = c2i(t[i]) -    if chrList[idx_s] == -1: -        chrList[idx_s] = idx_t +for ss, tt in zip(s, t): +    if d_s2t.get(ss) is None: +        d_s2t[ss] = tt -        if chrList[idx_s] != idx_t: +        if not d_s2t[ss] == tt: -# 変換先が重複していないことを調べる -# 変換先のインデックスchrList[i]に該当するchkをTrueにしていく -chk = [False for _ in range(26)] -for i in range(26): -    if chrList[i] == -1: -        pass -    elif not chk[chrList[i]]: -        chk[chrList[i]] = True +    if d_t2s.get(tt) is None: +        d_t2s[tt] = ss +        if not d_t2s[tt] == ss: +            flg = False +            break +if flg: +    if len(set(d_s2t.keys())) != len(set(d_s2t.values())): -        break +    if len(set(d_t2s.keys())) != len(set(d_t2s.values())): +        flg = False -# print(sorted(list(map(chr, list(map(lambda x: x + ord('a'), chrList))))))