import Data.List
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Vector.Storable as V

main = do
    s<-getLine
    t<-getLine
    putStrLn $ if check s t && check t s then "Yes" else "No"

check::String -> String -> Bool
check s t = all (==1) tl
    where
        al a (Just x) = Just (a:x)
        al a Nothing = Just [a]
        ms = foldl (\m (c,i) -> M.alter (al i) c m) M.empty $ zip s [0..]
        vt = V.fromList t
        tl = map (S.size . S.fromList . map (\i->vt V.! i)) $ M.elems ms