{-# LANGUAGE MultiWayIf #-}
import Control.Monad.ST
import Data.Array.MArray
import Data.Array.ST
import Debug.Trace (trace)

f :: [(Char,Char)] -> STUArray s Char Char -> ST s Bool
f [] _ = return True
f ((s,t):xs) arr = do
  c <- readArray arr t
  if | c=='-' -> do
          writeArray arr t s
          f xs arr
     | c==s -> f xs arr
     | otherwise -> return False

check xs ys = runST $ do
  arr <- newArray ('a','z') '-'
  f (zip xs ys) arr

solv ss ts = check ss ts && check ts ss

yesno True = "Yes"
yesno False = "No"

main = do
  ss <- getLine
  ts <- getLine
  putStrLn . yesno $ solv ss ts