local S, T = io.read("l","l")
S={string.byte(S,1,#S)}
T={string.byte(T,1,#T)}
local origin = {}
local result = {}
for i=1,#S do
    if origin[T[i]] == nil then
        origin[T[i]] = S[i];
    end
    if result[S[i]] == nil then
        result[S[i]] = T[i];
    end
    if origin[T[i]] ~= S[i] or result[S[i]] ~= T[i] then
        print("No")
        return
    end
end
print("Yes")
