Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

for i in range(0,len(s)-1):
	for j in range(i+1,len(s)):
		if(s[i]==s[j]):
			if(t[i]!=t[j]):
				print("No")
				sys.exit()
		else:
			if(t[i]==t[j]):
				print("No")
				sys.exit()
print("Yes")



Fixed submission:
# -*- coding: utf-8 -*-
#ABC110C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

checktable=[]
checktable2=[]
for i in range(0,26):
	checktable.append(0)
	checktable2.append(0)

for i in range(0,len(s)):
	index=ord(s[i])-ord("a")
	if(checktable[index]==0):
		checktable[index]=ord(t[i])-ord("a")
	else:
		if(checktable[index]!=ord(t[i])-ord("a")):
			print("No")
			sys.exit()
for i in range(0,len(s)):
	index=ord(t[i])-ord("a")
	if(checktable2[index]==0):
		checktable2[index]=ord(s[i])-ord("a")
	else:
		if(checktable2[index]!=ord(s[i])-ord("a")):
			print("No")
			sys.exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

for i in range(0,len(s)):
	for j in range(i,len(s)):
		if(s[i]==s[j]):
			if(t[i]!=t[j]):
				print("No")
				sys.exit()
		else:
			if(t[i]==t[j]):
				print("No")
				sys.exit()
print("Yes")



Fixed submission:
# -*- coding: utf-8 -*-
#ABC110C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

checktable=[]
checktable2=[]
for i in range(0,26):
	checktable.append(0)
	checktable2.append(0)

for i in range(0,len(s)):
	index=ord(s[i])-ord("a")
	if(checktable[index]==0):
		checktable[index]=ord(t[i])-ord("a")
	else:
		if(checktable[index]!=ord(t[i])-ord("a")):
			print("No")
			sys.exit()
for i in range(0,len(s)):
	index=ord(t[i])-ord("a")
	if(checktable2[index]==0):
		checktable2[index]=ord(s[i])-ord("a")
	else:
		if(checktable2[index]!=ord(s[i])-ord("a")):
			print("No")
			sys.exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

for i in range(0,len(s)):
	for j in range(i,len(s)):
		if(s[i]==s[j]):
			if(t[i]!=t[j]):
				print("No")
				sys.exit()
for i in range(0,len(t)):
	for j in range(i,len(t)):
		if(t[i]==t[j]):
			if(s[i]!=s[j]):
				print("No")
				sys.exit()
print("Yes")



Fixed submission:
# -*- coding: utf-8 -*-
#ABC110C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

checktable=[]
checktable2=[]
for i in range(0,26):
	checktable.append(0)
	checktable2.append(0)

for i in range(0,len(s)):
	index=ord(s[i])-ord("a")
	if(checktable[index]==0):
		checktable[index]=ord(t[i])-ord("a")
	else:
		if(checktable[index]!=ord(t[i])-ord("a")):
			print("No")
			sys.exit()
for i in range(0,len(s)):
	index=ord(t[i])-ord("a")
	if(checktable2[index]==0):
		checktable2[index]=ord(s[i])-ord("a")
	else:
		if(checktable2[index]!=ord(s[i])-ord("a")):
			print("No")
			sys.exit()
print("Yes")