# ABC120 C - String Transformation

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

nl = lambda: list(map(int, input().split()))



S = si()

T = si()

 

dict_S = {}

dict_T = {}

 

for i in range(len(S)):

    if S[i] in dict_S:

        if dict_S[S[i]] != T[i]:

            print("No")

            exit()

    else:

        dict_S[S[i]] = T[i]

        

    if T[i] in dict_T:

        if dict_T[T[i]] != S[i]:

            print("No")

            exit()

    else:

        dict_T[T[i]] = S[i]

        

print("Yes")
from collections import defaultdict as dd

s=eval(input())

t=eval(input())

ds=dd(int)

dt=dd(int)

for ss in s:

    ds[ss]+=1

for tt in t:

    dt[tt]+=1

# print(ds)

# print(dt)

ls,lt=[],[]

for k,v in list(ds.items()):

    ls.append(v)

for k,v in list(dt.items()):

    lt.append(v)

# print(ls)

# print(lt)

ls.sort()

lt.sort()

for a,b in zip(ls,lt):

    if a!=b:

        print('No')

        exit()

print('Yes')
# ABC120 C - String Transformation
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
S = si()
T = si()
dict_S = {}
dict_T = {}
for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
print("Yes")

from collections import defaultdict as dd

s = eval(input())
t = eval(input())
ds = dd(int)
dt = dd(int)
for ss in s:
    ds[ss] += 1
for tt in t:
    dt[tt] += 1
# print(ds)
# print(dt)
ls, lt = [], []
for k, v in list(ds.items()):
    ls.append(v)
for k, v in list(dt.items()):
    lt.append(v)
# print(ls)
# print(lt)
ls.sort()
lt.sort()
for a, b in zip(ls, lt):
    if a != b:
        print("No")
        exit()
print("Yes")

-# ABC120 C - String Transformation -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -nl = lambda: list(map(int, input().split())) -S = si() -T = si() -dict_S = {} -dict_T = {} -for i in range(len(S)): -    if S[i] in dict_S: -        if dict_S[S[i]] != T[i]: -            print("No") -            exit() -    else: -        dict_S[S[i]] = T[i] -    if T[i] in dict_T: -        if dict_T[T[i]] != S[i]: -            print("No") -            exit() -    else: -        dict_T[T[i]] = S[i] +from collections import defaultdict as dd + +s = eval(input()) +t = eval(input()) +ds = dd(int) +dt = dd(int) +for ss in s: +    ds[ss] += 1 +for tt in t: +    dt[tt] += 1 +# print(ds) +# print(dt) +ls, lt = [], [] +for k, v in list(ds.items()): +    ls.append(v) +for k, v in list(dt.items()): +    lt.append(v) +# print(ls) +# print(lt) +ls.sort() +lt.sort() +for a, b in zip(ls, lt): +    if a != b: +        print("No") +        exit()