S=io.read()
T=io.read()
s={}
t={}
for i=1,#S do
  s[i]=string.sub(S,i,i)
  t[i]=string.sub(T,i,i)
end
out="Yes"
for i=1,#S-1 do
  for j=i+1,#S do
    if s[i]==s[j] and t[i]~=t[j] then
      out="No"
      break
    end
  end
end
print(out)
