import qualified Data.Map as M                 

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 M.empty M.empty s t
  where
    go mpxy mpyx [] [] = True
    go mpxy mpyx (x : xs) (y : ys)
        | duplicated x y mpxy = False
        | duplicated y x mpyx = False
        | otherwise = go (M.insert x y mpxy) (M.insert y x mpyx) xs ys 

    duplicated k v mp = maybe False (/= v) $ M.lookup k mp