local s = {}
local t = {}
local checkt = {}
local checks = {}

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 ct = checkt[t[i]]
  local cs = checks[s[i]]
  if ct ~= s[i] and ct ~= nil then
      result = "No"
      break
  elseif cs ~= t[i] and cs ~= nil then 
      result = "No"
      break
  else
    checkt[t[i]] = s[i]
    checks[s[i]] = t[i]
  end
end

print(result)