def main():

    s = eval(input())

    t = eval(input())



    r = [[-1] * 26 for _ in range(2)]



    bl = True

    for se, te in zip(s, t):

        si = ord(se) - ord("a")

        ti = ord(te) - ord("a")



        if r[0][si] < 0:

            r[0][si] = ti

        else:

            if r[0][si] != ti:

                bl = False

                break



        if r[1][ti] < 0:

            r[1][ti] = si

        else:

            if r[1][ti] != si:

                bl = False

                break



    print(("Yes" if bl else "No"))





if __name__ == "__main__":

    main()

from collections import defaultdict



s = eval(input())

t = eval(input())



in_deg = defaultdict(set)

out_deg = defaultdict(set)



for es, et in zip(s, t):

    out_deg[es].add(et)

    in_deg[et].add(es)



in_deg_mx = max(list(map(len, list(in_deg.values()))))

out_deg_mx = max(list(map(len, list(out_deg.values()))))



if in_deg_mx <= 1 and out_deg_mx <= 1:

    ans = "Yes"

else:

    ans = "No"



print(ans)

def main():
    s = eval(input())
    t = eval(input())
    r = [[-1] * 26 for _ in range(2)]
    bl = True
    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")
        if r[0][si] < 0:
            r[0][si] = ti
        else:
            if r[0][si] != ti:
                bl = False
                break
        if r[1][ti] < 0:
            r[1][ti] = si
        else:
            if r[1][ti] != si:
                bl = False
                break
    print(("Yes" if bl else "No"))


if __name__ == "__main__":
    main()

from collections import defaultdict

s = eval(input())
t = eval(input())
in_deg = defaultdict(set)
out_deg = defaultdict(set)
for es, et in zip(s, t):
    out_deg[es].add(et)
    in_deg[et].add(es)
in_deg_mx = max(list(map(len, list(in_deg.values()))))
out_deg_mx = max(list(map(len, list(out_deg.values()))))
if in_deg_mx <= 1 and out_deg_mx <= 1:
    ans = "Yes"
else:
    ans = "No"
print(ans)

-def main(): -    s = eval(input()) -    t = eval(input()) -    r = [[-1] * 26 for _ in range(2)] -    bl = True -    for se, te in zip(s, t): -        si = ord(se) - ord("a") -        ti = ord(te) - ord("a") -        if r[0][si] < 0: -            r[0][si] = ti -        else: -            if r[0][si] != ti: -                bl = False -                break -        if r[1][ti] < 0: -            r[1][ti] = si -        else: -            if r[1][ti] != si: -                bl = False -                break -    print(("Yes" if bl else "No")) +from collections import defaultdict - -if __name__ == "__main__": -    main() +s = eval(input()) +t = eval(input()) +in_deg = defaultdict(set) +out_deg = defaultdict(set) +for es, et in zip(s, t): +    out_deg[es].add(et) +    in_deg[et].add(es) +in_deg_mx = max(list(map(len, list(in_deg.values())))) +out_deg_mx = max(list(map(len, list(out_deg.values())))) +if in_deg_mx <= 1 and out_deg_mx <= 1: +    ans = "Yes" +else: +    ans = "No" +print(ans)