import sys

s = str(eval(input()))

t = str(eval(input()))

l = len(s)

tmp = [[], []]

for i in range(l):

    if (not s[i] in tmp[0]) and (not t[i] in tmp[1]):

        tmp[0].append(s[i])

        tmp[1].append(t[i])

    else:

        if s[i] in tmp[0]:

            tmp2 = 0

            for j in range(len(tmp[0])):

                if s[i] == tmp[0][j]:

                    tmp2 = j

            if t[i] != tmp[1][tmp2]:

                print('No')

                sys.exit()

        else:

            print('No')

            sys.exit()

print('Yes')

import sys, re, os

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

def input(): return sys.stdin.readline().strip()

def STR(): return eval(input())

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def S_MAP(): return list(map(str, input().split()))

def LIST(): return list(map(int, input().split()))

def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)

inf = sys.maxsize

mod = 10 ** 9 + 7

dx = [0, 0, 1, -1, 1, -1, -1, 1]

dy = [1, -1, 0, 0, 1, -1, 1, -1]



s = STR()

t = STR()

l = len(s)

tmp = [[], []]

for i in range(len(s)):

    if not s[i] in tmp[0] and not t[i] in tmp[1]:

        tmp[0].append(s[i])

        tmp[1].append(t[i])

    else:

        if s[i] in tmp[0] and t[i] in tmp[1]:

            if tmp[0].index(s[i]) != tmp[1].index(t[i]):

                print('No')

                exit()

        else:

            print('No')

            exit()

print('Yes')



import sys

s = str(eval(input()))
t = str(eval(input()))
l = len(s)
tmp = [[], []]
for i in range(l):
    if (not s[i] in tmp[0]) and (not t[i] in tmp[1]):
        tmp[0].append(s[i])
        tmp[1].append(t[i])
    else:
        if s[i] in tmp[0]:
            tmp2 = 0
            for j in range(len(tmp[0])):
                if s[i] == tmp[0][j]:
                    tmp2 = j
            if t[i] != tmp[1][tmp2]:
                print("No")
                sys.exit()
        else:
            print("No")
            sys.exit()
print("Yes")

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input():
    return sys.stdin.readline().strip()


def STR():
    return eval(input())


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def S_MAP():
    return list(map(str, input().split()))


def LIST():
    return list(map(int, input().split()))


def S_LIST():
    return list(map(str, input().split()))


sys.setrecursionlimit(10**9)
inf = sys.maxsize
mod = 10**9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
s = STR()
t = STR()
l = len(s)
tmp = [[], []]
for i in range(len(s)):
    if not s[i] in tmp[0] and not t[i] in tmp[1]:
        tmp[0].append(s[i])
        tmp[1].append(t[i])
    else:
        if s[i] in tmp[0] and t[i] in tmp[1]:
            if tmp[0].index(s[i]) != tmp[1].index(t[i]):
                print("No")
                exit()
        else:
            print("No")
            exit()
print("Yes")

-import sys +import sys, re, os +from collections import deque, defaultdict, Counter +from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin +from itertools import permutations, combinations, product, accumulate +from operator import itemgetter, mul +from copy import deepcopy +from string import ascii_lowercase, ascii_uppercase, digits +from fractions import gcd -s = str(eval(input())) -t = str(eval(input())) + +def input(): +    return sys.stdin.readline().strip() + + +def STR(): +    return eval(input()) + + +def INT(): +    return int(eval(input())) + + +def MAP(): +    return list(map(int, input().split())) + + +def S_MAP(): +    return list(map(str, input().split())) + + +def LIST(): +    return list(map(int, input().split())) + + +def S_LIST(): +    return list(map(str, input().split())) + + +sys.setrecursionlimit(10**9) +inf = sys.maxsize +mod = 10**9 + 7 +dx = [0, 0, 1, -1, 1, -1, -1, 1] +dy = [1, -1, 0, 0, 1, -1, 1, -1] +s = STR() +t = STR() -for i in range(l): -    if (not s[i] in tmp[0]) and (not t[i] in tmp[1]): +for i in range(len(s)): +    if not s[i] in tmp[0] and not t[i] in tmp[1]: -        if s[i] in tmp[0]: -            tmp2 = 0 -            for j in range(len(tmp[0])): -                if s[i] == tmp[0][j]: -                    tmp2 = j -            if t[i] != tmp[1][tmp2]: +        if s[i] in tmp[0] and t[i] in tmp[1]: +            if tmp[0].index(s[i]) != tmp[1].index(t[i]): -                sys.exit() +                exit() -            sys.exit() +            exit()