def main():

    s, t = eval(input()), eval(input())



    s_dic, t_dic = {}, {}

    for i, j in zip(s, t):

        if i in s_dic and s_dic[i] != j:

            print("No")

            exit()



        if j in t_dic and t_dic[j] != i:

            print("No")

            exit()



        s_dic[i], t_dic[j] = j, i



    print("Yes")





if __name__ == '__main__':

    main()

def main():

    s, t = eval(input()), eval(input())



    used, dic = [0] * 512, {}

    for i in range(26):

        dic[chr(ord('a')+i)] = chr(ord('a')+i)



    for i, j in zip(s, t):

        if dic[i] == j:

            used[ord(i)] = 1

            continue



        for k, v in list(dic.items()):

            if v == j:

                if used[ord(k)]:

                    print("No")

                    exit()

                dic[k] = i



        if used[ord(i)] and dic[i] != j:

            print("No")

            exit()



        dic[i], used[ord(i)] = j, 1



    print("Yes")





if __name__ == '__main__':

    main()

def main():
    s, t = eval(input()), eval(input())
    s_dic, t_dic = {}, {}
    for i, j in zip(s, t):
        if i in s_dic and s_dic[i] != j:
            print("No")
            exit()
        if j in t_dic and t_dic[j] != i:
            print("No")
            exit()
        s_dic[i], t_dic[j] = j, i
    print("Yes")


if __name__ == "__main__":
    main()

def main():
    s, t = eval(input()), eval(input())
    used, dic = [0] * 512, {}
    for i in range(26):
        dic[chr(ord("a") + i)] = chr(ord("a") + i)
    for i, j in zip(s, t):
        if dic[i] == j:
            used[ord(i)] = 1
            continue
        for k, v in list(dic.items()):
            if v == j:
                if used[ord(k)]:
                    print("No")
                    exit()
                dic[k] = i
        if used[ord(i)] and dic[i] != j:
            print("No")
            exit()
        dic[i], used[ord(i)] = j, 1
    print("Yes")


if __name__ == "__main__":
    main()

-    s_dic, t_dic = {}, {} +    used, dic = [0] * 512, {} +    for i in range(26): +        dic[chr(ord("a") + i)] = chr(ord("a") + i) -        if i in s_dic and s_dic[i] != j: +        if dic[i] == j: +            used[ord(i)] = 1 +            continue +        for k, v in list(dic.items()): +            if v == j: +                if used[ord(k)]: +                    print("No") +                    exit() +                dic[k] = i +        if used[ord(i)] and dic[i] != j: -        if j in t_dic and t_dic[j] != i: -            print("No") -            exit() -        s_dic[i], t_dic[j] = j, i +        dic[i], used[ord(i)] = j, 1