import Data.Function
import Data.List
main =  do
  s <- getLine
  t <- getLine
  let a = all ((==) 1 . length) . groupBy ((==) `on` fst) . sortOn fst . nub $ zip s t
      b = all ((==) 1 . length) . groupBy ((==) `on` snd) . sortOn snd . nub $ zip s t
  putStrLn $ if a && b then "Yes" else "No"