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 set [] [] = True
        go set (x:xs) (y:ys)
            | x == y = go set xs ys
            | y `S.member` set = False
            | otherwise = go (S.insert y set) (map (replace x y) xs) ys

        replace x y c = if c == x then y else c