def main():

    S = input()

    T = input()

    from collections import defaultdict

    tran = defaultdict(set)

    rtran = defaultdict(set)

    for s, t in zip(S, T):

        tran[s].add(t)

        rtran[t].add(s)

    if all(len(v) <= 1 for v in tran.values()) and \

            all(len(v) <= 1 for v in rtran.values()):

        print("Yes")

    else:

        print("No")





if __name__ == '__main__':

    main()

def main():

    from string import ascii_lowercase

    S = input()

    T = input()



    dic1 = {a: set() for a in ascii_lowercase}

    dic2 = {a: set() for a in ascii_lowercase}

    for s, t in zip(S, T):

        dic1[s].add(t)

        dic2[t].add(s)

    if all(len(s) <= 1 for s in dic1.values()) and\

            all(len(s) <= 1 for s in dic2.values()):

        print("Yes")

    else:

        print("No")





if __name__ == '__main__':

    main()

def main():
    S = input()
    T = input()
    from collections import defaultdict

    tran = defaultdict(set)
    rtran = defaultdict(set)
    for s, t in zip(S, T):
        tran[s].add(t)
        rtran[t].add(s)
    if all(len(v) <= 1 for v in tran.values()) and all(
        len(v) <= 1 for v in rtran.values()
    ):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

def main():
    from string import ascii_lowercase

    S = input()
    T = input()
    dic1 = {a: set() for a in ascii_lowercase}
    dic2 = {a: set() for a in ascii_lowercase}
    for s, t in zip(S, T):
        dic1[s].add(t)
        dic2[t].add(s)
    if all(len(s) <= 1 for s in dic1.values()) and all(
        len(s) <= 1 for s in dic2.values()
    ):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

+    from string import ascii_lowercase + -    from collections import defaultdict - -    tran = defaultdict(set) -    rtran = defaultdict(set) +    dic1 = {a: set() for a in ascii_lowercase} +    dic2 = {a: set() for a in ascii_lowercase} -        tran[s].add(t) -        rtran[t].add(s) -    if all(len(v) <= 1 for v in tran.values()) and all( -        len(v) <= 1 for v in rtran.values() +        dic1[s].add(t) +        dic2[t].add(s) +    if all(len(s) <= 1 for s in dic1.values()) and all( +        len(s) <= 1 for s in dic2.values()