import qualified Data.Map as M
import Control.Monad.Trans.State

data Acc = Acc
  { mpxy :: M.Map Char Char
  , mpyx :: M.Map Char Char
  , strx :: String
  , stry :: String
  }

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

solve :: String -> String -> Bool
solve s t = evalState nullCheckStep $ Acc M.empty M.empty s t
  where
    nullCheckStep = do
      Acc _ _ strx stry <- get
      if null strx && null stry
        then return True
        else dupCheckStep

    dupCheckStep = do
      Acc mpxy mpyx (x:_) (y:_) <- get
      if duplicated x y mpxy || duplicated y x mpyx
        then return False
        else insertStep

    insertStep = do
      Acc mpxy mpyx (x:xs) (y:ys) <- get
      put $ Acc (M.insert x y mpxy) (M.insert y x mpyx) xs ys
      nullCheckStep

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