S = eval(input())

T = eval(input())



SS = [s for s in S]

SS_set = list(set(SS))

CS = []

for c in SS_set:

  C_idx_in_S = [i for i, x in enumerate(SS) if x==c]

  if len(C_idx_in_S) > 1:

    CS.append(C_idx_in_S)



TT = [t for t in T]

TT_set = list(set(TT))

CT = []

for c in TT_set:

  C_idx_in_T = [i for i, x in enumerate(TT) if x==c]

  if len(C_idx_in_T) > 1:

    CT.append(C_idx_in_T)



if len(CS) == len(CT):

  for i in CS:

    if i in CT:

      continue

    else:

      print("No")

      break

  else:

    print("Yes")

else:

  print("No")
#解説

S = eval(input())

T = eval(input())



start = [-1]*26

goal = [-1]*26



for i in range(len(S)):

  a = ord(S[i]) - ord("a")

  b = ord(T[i]) - ord("a")

  

  if start[a] != -1 or goal[b] != -1:

    if start[a] != b or goal[b] != a:

      print("No")

      break

  else:

    start[a] = b

    goal[b] = a

else:

  print("Yes")
S = eval(input())
T = eval(input())
SS = [s for s in S]
SS_set = list(set(SS))
CS = []
for c in SS_set:
    C_idx_in_S = [i for i, x in enumerate(SS) if x == c]
    if len(C_idx_in_S) > 1:
        CS.append(C_idx_in_S)
TT = [t for t in T]
TT_set = list(set(TT))
CT = []
for c in TT_set:
    C_idx_in_T = [i for i, x in enumerate(TT) if x == c]
    if len(C_idx_in_T) > 1:
        CT.append(C_idx_in_T)
if len(CS) == len(CT):
    for i in CS:
        if i in CT:
            continue
        else:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")

# 解説
S = eval(input())
T = eval(input())
start = [-1] * 26
goal = [-1] * 26
for i in range(len(S)):
    a = ord(S[i]) - ord("a")
    b = ord(T[i]) - ord("a")
    if start[a] != -1 or goal[b] != -1:
        if start[a] != b or goal[b] != a:
            print("No")
            break
    else:
        start[a] = b
        goal[b] = a
else:
    print("Yes")

+# 解説 -SS = [s for s in S] -SS_set = list(set(SS)) -CS = [] -for c in SS_set: -    C_idx_in_S = [i for i, x in enumerate(SS) if x == c] -    if len(C_idx_in_S) > 1: -        CS.append(C_idx_in_S) -TT = [t for t in T] -TT_set = list(set(TT)) -CT = [] -for c in TT_set: -    C_idx_in_T = [i for i, x in enumerate(TT) if x == c] -    if len(C_idx_in_T) > 1: -        CT.append(C_idx_in_T) -if len(CS) == len(CT): -    for i in CS: -        if i in CT: -            continue -        else: +start = [-1] * 26 +goal = [-1] * 26 +for i in range(len(S)): +    a = ord(S[i]) - ord("a") +    b = ord(T[i]) - ord("a") +    if start[a] != -1 or goal[b] != -1: +        if start[a] != b or goal[b] != a: -        print("Yes") +        start[a] = b +        goal[b] = a -    print("No") +    print("Yes")