input = open(0).read

S, T = input().split()





def main():

    C1 = [None] * (ord('z') - ord('a') + 1)

    C2 = [None] * (ord('z') - ord('a') + 1)



    flg = True



    for i in range(len(S)):

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

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



        if C1[c1] or C2[c2]:

            if c1 != C2[c2] or c2 != C1[c1]:

                flg = False

                break



        C1[c1] = c2

        C2[c2] = c1



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

    return





main()

#from sys import stdin

from collections import Counter

from operator import itemgetter



#input = stdin.readline



S = list(eval(input()))

T = list(eval(input()))





def main():

    C1 = Counter(S).most_common()

    C2 = Counter(T).most_common()



    if len(C1) != len(C2):

        print("No")

        return



    flg = True

    for i in range(len(C1)):

        if C1[i][1] != C2[i][1]:

            flg = False



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

    return





main()

input = open(0).read
S, T = input().split()


def main():
    C1 = [None] * (ord("z") - ord("a") + 1)
    C2 = [None] * (ord("z") - ord("a") + 1)
    flg = True
    for i in range(len(S)):
        c1 = ord(S[i]) - ord("a")
        c2 = ord(T[i]) - ord("a")
        if C1[c1] or C2[c2]:
            if c1 != C2[c2] or c2 != C1[c1]:
                flg = False
                break
        C1[c1] = c2
        C2[c2] = c1
    print(("Yes" if flg else "No"))
    return


main()

# from sys import stdin
from collections import Counter
from operator import itemgetter

# input = stdin.readline
S = list(eval(input()))
T = list(eval(input()))


def main():
    C1 = Counter(S).most_common()
    C2 = Counter(T).most_common()
    if len(C1) != len(C2):
        print("No")
        return
    flg = True
    for i in range(len(C1)):
        if C1[i][1] != C2[i][1]:
            flg = False
    print(("Yes" if flg else "No"))
    return


main()

-input = open(0).read -S, T = input().split() +# from sys import stdin +from collections import Counter +from operator import itemgetter + +# input = stdin.readline +S = list(eval(input())) +T = list(eval(input())) -    C1 = [None] * (ord("z") - ord("a") + 1) -    C2 = [None] * (ord("z") - ord("a") + 1) +    C1 = Counter(S).most_common() +    C2 = Counter(T).most_common() +    if len(C1) != len(C2): +        print("No") +        return -    for i in range(len(S)): -        c1 = ord(S[i]) - ord("a") -        c2 = ord(T[i]) - ord("a") -        if C1[c1] or C2[c2]: -            if c1 != C2[c2] or c2 != C1[c1]: -                flg = False -                break -        C1[c1] = c2 -        C2[c2] = c1 +    for i in range(len(C1)): +        if C1[i][1] != C2[i][1]: +            flg = False