import qualified Data.Map as Map

f::Map.Map Char Char->String->String->String
f _ [] []="Yes"
f ms (x:xs) (y:ys)=if (Map.lookup y ms)==Nothing then
            f (Map.insert y x ms) xs ys
         else let (Just t)=Map.lookup y ms
              in if not (t==x) then "No"
                 else f ms xs ys

main = do
       xs<-getLine
       ys<-getLine
       let ms=Map.fromList [('A','A')]
       putStrLn $ f ms xs ys