#!usr/bin/env python3

from collections import defaultdict

from collections import deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return list(map(int, sys.stdin.readline().split()))

def I(): return int(sys.stdin.readline())

def LS():return list(map(list, sys.stdin.readline().split()))

def S(): return list(sys.stdin.readline())[:-1]

def IR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = I()

    return l

def LIR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LI()

    return l

def SR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = S()

    return l

def LSR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = SR()

    return l

mod = 1000000007

sys.setrecursionlimit(1000000)



#A

def A():

    return



#B

def B():

    return



#C

def C():

    s = S()

    t = S()

    n = len(s)

    d = defaultdict(list)

    for i in range(n):

        d[s[i]].append(t[i])

    d2 = defaultdict(list)

    for i in range(n):

        d2[t[i]].append(s[i])

    for i in list(d.keys()):

        k = d[i]

        k = list(set(d[i]))

        if len(k) > 1:

            print("No")

            quit()

    for i in list(d2.keys()):

        k = d2[i]

        k = list(set(d2[i]))

        if len(k) > 1:

            print("No")

            quit()

    print("Yes")

#D

def D():

    return



#E

def E():

    return



#F

def F():

    return



#G

def G():

    return



#H

def H():

    return



#Solve

if __name__ == "__main__":

    C()

#!usr/bin/env python3

from collections import defaultdict,deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS():return [list(x) for x in sys.stdin.readline().split()]

def S():

    res = list(sys.stdin.readline())

    if res[-1] == "\n":

        return res[:-1]

    return res



def IR(n):

    return [I() for i in range(n)]

def LIR(n):

    return [LI() for i in range(n)]

def SR(n):

    return [S() for i in range(n)]

def LSR(n):

    return [LS() for i in range(n)]



sys.setrecursionlimit(1000000)

mod = 1000000007



s = eval(input())

t = eval(input())

f = defaultdict(lambda : None)

for i in range(len(s)):

    si,ti = s[i],t[i]

    if f[si] != None:

        if f[si] != ti:

            print("No")

            quit()

    else:

        f[si] = ti

f = defaultdict(lambda : None)

for i in range(len(s)):

    si,ti = s[i],t[i]

    if f[ti] != None:

        if f[ti] != si:

            print("No")

            quit()

    else:

        f[ti] = si



print("Yes")

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random


def LI():
    return list(map(int, sys.stdin.readline().split()))


def I():
    return int(sys.stdin.readline())


def LS():
    return list(map(list, sys.stdin.readline().split()))


def S():
    return list(sys.stdin.readline())[:-1]


def IR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = I()
    return l


def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LI()
    return l


def SR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = S()
    return l


def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = SR()
    return l


mod = 1000000007
sys.setrecursionlimit(1000000)
# A
def A():
    return


# B
def B():
    return


# C
def C():
    s = S()
    t = S()
    n = len(s)
    d = defaultdict(list)
    for i in range(n):
        d[s[i]].append(t[i])
    d2 = defaultdict(list)
    for i in range(n):
        d2[t[i]].append(s[i])
    for i in list(d.keys()):
        k = d[i]
        k = list(set(d[i]))
        if len(k) > 1:
            print("No")
            quit()
    for i in list(d2.keys()):
        k = d2[i]
        k = list(set(d2[i]))
        if len(k) > 1:
            print("No")
            quit()
    print("Yes")


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# G
def G():
    return


# H
def H():
    return


# Solve
if __name__ == "__main__":
    C()

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def I():
    return int(sys.stdin.readline())


def LS():
    return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007
s = eval(input())
t = eval(input())
f = defaultdict(lambda: None)
for i in range(len(s)):
    si, ti = s[i], t[i]
    if f[si] != None:
        if f[si] != ti:
            print("No")
            quit()
    else:
        f[si] = ti
f = defaultdict(lambda: None)
for i in range(len(s)):
    si, ti = s[i], t[i]
    if f[ti] != None:
        if f[ti] != si:
            print("No")
            quit()
    else:
        f[ti] = si
print("Yes")

-from collections import defaultdict -from collections import deque +from collections import defaultdict, deque -    return list(map(int, sys.stdin.readline().split())) +    return [int(x) for x in sys.stdin.readline().split()] -    return list(map(list, sys.stdin.readline().split())) +    return [list(x) for x in sys.stdin.readline().split()] -    return list(sys.stdin.readline())[:-1] +    res = list(sys.stdin.readline()) +    if res[-1] == "\n": +        return res[:-1] +    return res -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = I() -    return l +    return [I() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = LI() -    return l +    return [LI() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = S() -    return l +    return [S() for i in range(n)] -    l = [None for i in range(n)] -    for i in range(n): -        l[i] = SR() -    return l +    return [LS() for i in range(n)] +sys.setrecursionlimit(1000000) -sys.setrecursionlimit(1000000) -# A -def A(): -    return - - -# B -def B(): -    return - - -# C -def C(): -    s = S() -    t = S() -    n = len(s) -    d = defaultdict(list) -    for i in range(n): -        d[s[i]].append(t[i]) -    d2 = defaultdict(list) -    for i in range(n): -        d2[t[i]].append(s[i]) -    for i in list(d.keys()): -        k = d[i] -        k = list(set(d[i])) -        if len(k) > 1: +s = eval(input()) +t = eval(input()) +f = defaultdict(lambda: None) +for i in range(len(s)): +    si, ti = s[i], t[i] +    if f[si] != None: +        if f[si] != ti: -    for i in list(d2.keys()): -        k = d2[i] -        k = list(set(d2[i])) -        if len(k) > 1: +    else: +        f[si] = ti +f = defaultdict(lambda: None) +for i in range(len(s)): +    si, ti = s[i], t[i] +    if f[ti] != None: +        if f[ti] != si: -    print("Yes") - - -# D -def D(): -    return - - -# E -def E(): -    return - - -# F -def F(): -    return - - -# G -def G(): -    return - - -# H -def H(): -    return - - -# Solve -if __name__ == "__main__": -    C() +    else: +        f[ti] = si +print("Yes")