local s = io.read()
local t = io.read()
local n = #s
local tbl1, tbl2 = {}, {}
for i = 1, 26 do tbl1[i] = 0 tbl2[i] = 0 end
local isok = true
for i = 1, n do
  local ssub, tsub = s:sub(i, i):byte(), t:sub(i, i):byte()
  ssub, tsub = ssub - 96, tsub - 96
  if tbl1[ssub] ~= 0 and tbl1[ssub] ~= tsub then
    isok = false break
  end
  if tbl2[tsub] ~= 0 and tbl2[tsub] ~= ssub then
    isok = false break
  end
  tbl1[ssub] = tsub
  tbl2[tsub] = ssub
end
print(isok and "Yes" or "No")
