import Data.Char (ord)
import qualified Data.Map as M

toSwapMap :: String -> String -> Maybe (M.Map Char Char)
toSwapMap ss ts = foldr helper (Just M.empty) $ zip ss ts
  where helper (s,t) m = do
          m' <- m
          case m' M.!? s of
            Nothing -> return (M.insert s t m')
            Just u -> if t == u then m else Nothing

canSwap ss ts = (toSwapMap ss ts /= Nothing) && (toSwapMap ts ss /= Nothing)

main = do
  ss <- getLine
  ts <- getLine
  if canSwap ss ts
    then putStrLn "Yes"
    else putStrLn "No"
