import Data.List

code :: String -> [Int]
code [] = []
code [x] = [1]
code (x:y:l) = if x==y then (1+(head $ code $ y:l)):(tail $ code $ y:l)
                       else 1:(code $ y:l)

main :: IO ()
main = do
  l <- sort <$> getLine
  r <- sort <$> getLine
  if ((length l) == (length r)) && (code l) == (code r)) then putStrLn "Yes" else putStrLn "No"
