import qualified Data.Set as S

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    putStrLn $ if solve s t then "Yes" else "No"

solve :: String -> String -> Bool
solve s t = go S.empty s t
  where
    go _   []       []       = True
    go set (x : xs) (y : ys)
        | x == y && x `elem` xs = False
        | x == y && y `elem` ys = False
        | x == y = go (S.insert x set) xs ys
        | x /= y && x `S.member` set = False
        | x /= y && y `S.member` set = False
        | x /= y = go (S.insert y set) (map (replace x y) xs) ys

    replace c1 c2 x
        | x == c1 = c2
        | x == c2 = c1
        | otherwise = x