import qualified Data.Map as Map
import Data.Maybe

type Map = Map.Map Char Int

solve :: String -> Int -> Map -> [Int]
solve [] _ _ = []
solve (s:ss) i m = result : solve ss nexti nextm
  where saved = fromMaybe (-1) $ Map.lookup s m
        result = if saved < 0 then i else saved
        nexti = if saved < 0 then i + 1 else i
        nextm = Map.insert s result m

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  let rs = solve s 0 Map.empty
  let rt = solve t 0 Map.empty
  putStrLn $ if rs == rt then "Yes" else "No"