import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.Map as M

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve s t = if uniq s t && uniq t s then "Yes" else "No"

uniq s t = case foldr op (Just M.empty) (zip s t) of
              Nothing -> False
              Just _ -> True
  where
    op (c1,c2) Nothing = Nothing
    op (c1,c2) (Just mp) =
      case M.lookup c1 mp of
        Nothing -> Just (M.insert c1 c2 mp)
        Just c0 -> if c0 == c2 then Just mp else Nothing


main = do
  conts <- B.getContents
  let [s,t] = B.words conts
      s1 = B.unpack s
      t1 = B.unpack t
      ans = solve s1 t1
  putStrLn ans
