from collections import Counter



S,T = Counter([s for s in eval(input())]), Counter([s for s in eval(input())])

print(('Yes' if Counter(list(S.values())) ==  Counter(list(T.values())) else 'No'))
import collections



cntS = collections.Counter(eval(input()))

cntT = collections.Counter(eval(input()))



if sorted(cntS.values()) == sorted(cntT.values()):

    print('Yes')

else:

    print('No')



from collections import Counter

S, T = Counter([s for s in eval(input())]), Counter([s for s in eval(input())])
print(("Yes" if Counter(list(S.values())) == Counter(list(T.values())) else "No"))

import collections

cntS = collections.Counter(eval(input()))
cntT = collections.Counter(eval(input()))
if sorted(cntS.values()) == sorted(cntT.values()):
    print("Yes")
else:
    print("No")

-from collections import Counter +import collections -S, T = Counter([s for s in eval(input())]), Counter([s for s in eval(input())]) -print(("Yes" if Counter(list(S.values())) == Counter(list(T.values())) else "No")) +cntS = collections.Counter(eval(input())) +cntT = collections.Counter(eval(input())) +if sorted(cntS.values()) == sorted(cntT.values()): +    print("Yes") +else: +    print("No")