def main():

    S = eval(input())

    T = eval(input())



    start = [-1] * 26

    goal = [-1] * 26



    for i in range(len(S)):

        a = ord(S[i]) - ord('a')

        b = ord(T[i]) - ord('a')



        if start[a] != -1 or goal[b] != -1:

            if start[a] != b or goal[b] != a:

                print('No')

                exit()

        

        start[a] = b

        goal[b] = a

    

    print('Yes')



main()
from collections import Counter



def main():

    S = eval(input())

    T = eval(input())

    cnt_S = []

    cnt_T = []

    for i, j in list(Counter(S).items()):

        cnt_S.append(j)

    for i, j in list(Counter(T).items()):

        cnt_T.append(j)



    cnt_S.sort()

    cnt_T.sort()

    if cnt_T == cnt_S:

        print('Yes')

    else:

        print('No')





if __name__ == "__main__":

    main()
def main():
    S = eval(input())
    T = eval(input())
    start = [-1] * 26
    goal = [-1] * 26
    for i in range(len(S)):
        a = ord(S[i]) - ord("a")
        b = ord(T[i]) - ord("a")
        if start[a] != -1 or goal[b] != -1:
            if start[a] != b or goal[b] != a:
                print("No")
                exit()
        start[a] = b
        goal[b] = a
    print("Yes")


main()

from collections import Counter


def main():
    S = eval(input())
    T = eval(input())
    cnt_S = []
    cnt_T = []
    for i, j in list(Counter(S).items()):
        cnt_S.append(j)
    for i, j in list(Counter(T).items()):
        cnt_T.append(j)
    cnt_S.sort()
    cnt_T.sort()
    if cnt_T == cnt_S:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

+from collections import Counter + + -    start = [-1] * 26 -    goal = [-1] * 26 -    for i in range(len(S)): -        a = ord(S[i]) - ord("a") -        b = ord(T[i]) - ord("a") -        if start[a] != -1 or goal[b] != -1: -            if start[a] != b or goal[b] != a: -                print("No") -                exit() -        start[a] = b -        goal[b] = a -    print("Yes") +    cnt_S = [] +    cnt_T = [] +    for i, j in list(Counter(S).items()): +        cnt_S.append(j) +    for i, j in list(Counter(T).items()): +        cnt_T.append(j) +    cnt_S.sort() +    cnt_T.sort() +    if cnt_T == cnt_S: +        print("Yes") +    else: +        print("No") -main() +if __name__ == "__main__": +    main()