from sys import stdin

import fractions



s = stdin.readline().rstrip()

t = stdin.readline().rstrip()



li = []

for i in range(len(s)):

    li.append((s[i],t[i]))

li.sort()



for i in range(len(li)-1):

    if li[i][0] == li[i+1][0]:

        if li[i][1] != li[i+1][1]:

            print("No")

            exit()



li.sort(key=lambda x:(x[1]))



for i in range(len(li)-1):

    if li[i][0] != li[i+1][0]:

        if li[i][1] == li[i+1][1]:

            print("No")

            exit()



print("Yes")
s = eval(input())

t = eval(input())



dic = {}

dic2 = {}



for i,j in zip(s,t):

    if j not in dic:

        if i in dic2:

            print("No")

            exit()

        dic[j] = i

        dic2[i] = j

    else:

        if dic[j] != i:

            print("No")

            exit()

print("Yes")
from sys import stdin
import fractions

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
li = []
for i in range(len(s)):
    li.append((s[i], t[i]))
li.sort()
for i in range(len(li) - 1):
    if li[i][0] == li[i + 1][0]:
        if li[i][1] != li[i + 1][1]:
            print("No")
            exit()
li.sort(key=lambda x: (x[1]))
for i in range(len(li) - 1):
    if li[i][0] != li[i + 1][0]:
        if li[i][1] == li[i + 1][1]:
            print("No")
            exit()
print("Yes")

s = eval(input())
t = eval(input())
dic = {}
dic2 = {}
for i, j in zip(s, t):
    if j not in dic:
        if i in dic2:
            print("No")
            exit()
        dic[j] = i
        dic2[i] = j
    else:
        if dic[j] != i:
            print("No")
            exit()
print("Yes")

-from sys import stdin -import fractions - -s = stdin.readline().rstrip() -t = stdin.readline().rstrip() -li = [] -for i in range(len(s)): -    li.append((s[i], t[i])) -li.sort() -for i in range(len(li) - 1): -    if li[i][0] == li[i + 1][0]: -        if li[i][1] != li[i + 1][1]: +s = eval(input()) +t = eval(input()) +dic = {} +dic2 = {} +for i, j in zip(s, t): +    if j not in dic: +        if i in dic2: -li.sort(key=lambda x: (x[1])) -for i in range(len(li) - 1): -    if li[i][0] != li[i + 1][0]: -        if li[i][1] == li[i + 1][1]: +        dic[j] = i +        dic2[i] = j +    else: +        if dic[j] != i: