a = io.read()
b = io.read()
t = {}
local function solve()
	for i = 1, #a do
		c1 = a:sub(i,i)
		c2 = b:sub(i,i)
		if c1 ~= c2 then
			if not t[c1] and not t[c2] then
				t[c1] = c2
				t[c2] = c1

			elseif t[c1] ~= c2 or t[c2] ~= c1 then
				return "No"
			end
		end
	end
	return "Yes"
end
print(solve())