a = io.read()
b = io.read()
-- a = "abcdefghijklmnopqrstuvwxyz"
-- b = "ibyhqfrekavclxjstdwgpzmonu"
t1 = {}
t2 = {}
local function f(t, a, i)
	c = a:sub(i,i)
	t[c] = t[c] or 0
	t[c] = t[c] + 1
end
for i = 1, #a do
	f(t1, a, i)
	f(t2, b, i)
end

local function solve()
	for i = 1, #a do
		c1 = a:sub(i,i)
		c2 = b:sub(i,i)
		if t1[c1] ~= t2[c2] then
			return "No"
		end
	end
	return "Yes"
end
print(solve())