local s = {}
local t = {}
local check = {}

for v in string.gmatch(io.read(), "%w") do
  table.insert(s, v)
end

for v in string.gmatch(io.read(), "%w") do
  table.insert(t, v)
end

local result = "Yes"
for i = 1, #s do
  local c = check[t[i]]
  if c ~= nil and c ~= s[i] then
    result = "No"
    break
  else
    check[t[i]] = s[i]
  end
end

print(result)