import qualified Data.Array as A

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  let tab = mkMap (s, t)
  putStrLn $ if tab then "Yes" else "No"
  return ()

solve :: (String, String) -> Bool
solve (s, t) = mkMap (s, t)


type Tab = A.Array Char Int

mkMap :: (String, String) -> Bool
mkMap (s, t) = let f e a
                     | e < 0 = fromEnum a
                     | otherwise = if e == fromEnum a then fromEnum a else (-2)
                   mk = A.accumArray f (-1) ('a', 'z')
                   as = mk (zip s t)
                   bs = mk (zip t s)
                   check = all (\(_, i) -> i /= (-2)) . A.assocs
               in
                 check as && check bs
