import qualified Data.Map as M

(!?) :: Ord k => M.Map k a -> k -> Maybe a
m !? k
  | M.member k m = Just $ m M.! k
  | otherwise = Nothing

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' !? 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"
