import Data.List
import Data.Tuple

main = do
    s <- getLine
    t <- getLine
    let p1 = sort $ zip s t
        p2 = sort $ zip t s
    putStrLn $ if check p1 && check p2 then "Yes" else "No"
        
check [] = True
check [a] = True
check ((a,b):(c,d):es) | a == c && b /= d = False
                       | otherwise = check ((c,d):es)