def main():

    s = eval(input())

    t = eval(input())



    dt = dict()

    ds = dict()

    for i in range(len(s)):

        if t[i] not in dt:

            dt[t[i]] = s[i]

        else:

            if dt[t[i]] != s[i]:

                print("No")

                return



        if s[i] not in ds:

            ds[s[i]] = t[i]

        else:

            if ds[s[i]] != t[i]:

                print("No")

                return



    print("Yes")



if __name__ == "__main__":

    main()
#提出3250967より



from collections import Counter

 

S = eval(input())

T = eval(input())

 

s = Counter(S)

t = Counter(T)

 

if sorted(s.values()) == sorted(t.values()):

	print("Yes")

else:

	print("No")
def main():
    s = eval(input())
    t = eval(input())
    dt = dict()
    ds = dict()
    for i in range(len(s)):
        if t[i] not in dt:
            dt[t[i]] = s[i]
        else:
            if dt[t[i]] != s[i]:
                print("No")
                return
        if s[i] not in ds:
            ds[s[i]] = t[i]
        else:
            if ds[s[i]] != t[i]:
                print("No")
                return
    print("Yes")


if __name__ == "__main__":
    main()

# 提出3250967より
from collections import Counter

S = eval(input())
T = eval(input())
s = Counter(S)
t = Counter(T)
if sorted(s.values()) == sorted(t.values()):
    print("Yes")
else:
    print("No")

-def main(): -    s = eval(input()) -    t = eval(input()) -    dt = dict() -    ds = dict() -    for i in range(len(s)): -        if t[i] not in dt: -            dt[t[i]] = s[i] -        else: -            if dt[t[i]] != s[i]: -                print("No") -                return -        if s[i] not in ds: -            ds[s[i]] = t[i] -        else: -            if ds[s[i]] != t[i]: -                print("No") -                return +# 提出3250967より +from collections import Counter + +S = eval(input()) +T = eval(input()) +s = Counter(S) +t = Counter(T) +if sorted(s.values()) == sorted(t.values()): - - -if __name__ == "__main__": -    main() +else: +    print("No")