def main():

    S=eval(input())

    T=eval(input())

    X=[]

    Y=[]

    flag=True

    for i in range(len(S)):

        al=False

        if T[i] in Y:

            al=True

            if X[Y.index(T[i])]!=S[i]:

                flag=False

                break

        if S[i] in X:

            al=True

            if Y[X.index(S[i])]!=T[i]:

                flag=False

                break

        if al==False:

            X.append(S[i])

            Y.append(T[i])

    if flag:

        print("Yes")

    else:

        print("No")



if __name__=="__main__":

    main()
from sys import stdin

def main():

    #入力

    readline=stdin.readline

    S=readline().strip()

    T=readline().strip()



    d=dict()

    for i in range(len(S)):

        if S[i] not in d:

            d[S[i]]=T[i]

        else:

            if d[S[i]]!=T[i]:

                print("No")

                break

    else:

        li=list(d.items())

        d2=dict()

        for cs in li:

            c1=cs[0]

            c2=cs[1]

            if c2 not in d2:

                d2[c2]=c1

            else:

                if d2[c2]!=c1:

                    print("No")

                    break

        else:

            print("Yes")

if __name__=="__main__":

    main()
def main():
    S = eval(input())
    T = eval(input())
    X = []
    Y = []
    flag = True
    for i in range(len(S)):
        al = False
        if T[i] in Y:
            al = True
            if X[Y.index(T[i])] != S[i]:
                flag = False
                break
        if S[i] in X:
            al = True
            if Y[X.index(S[i])] != T[i]:
                flag = False
                break
        if al == False:
            X.append(S[i])
            Y.append(T[i])
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

from sys import stdin


def main():
    # 入力
    readline = stdin.readline
    S = readline().strip()
    T = readline().strip()
    d = dict()
    for i in range(len(S)):
        if S[i] not in d:
            d[S[i]] = T[i]
        else:
            if d[S[i]] != T[i]:
                print("No")
                break
    else:
        li = list(d.items())
        d2 = dict()
        for cs in li:
            c1 = cs[0]
            c2 = cs[1]
            if c2 not in d2:
                d2[c2] = c1
            else:
                if d2[c2] != c1:
                    print("No")
                    break
        else:
            print("Yes")


if __name__ == "__main__":
    main()

+from sys import stdin + + -    S = eval(input()) -    T = eval(input()) -    X = [] -    Y = [] -    flag = True +    # 入力 +    readline = stdin.readline +    S = readline().strip() +    T = readline().strip() +    d = dict() -        al = False -        if T[i] in Y: -            al = True -            if X[Y.index(T[i])] != S[i]: -                flag = False +        if S[i] not in d: +            d[S[i]] = T[i] +        else: +            if d[S[i]] != T[i]: +                print("No") -        if S[i] in X: -            al = True -            if Y[X.index(S[i])] != T[i]: -                flag = False -                break -        if al == False: -            X.append(S[i]) -            Y.append(T[i]) -    if flag: -        print("Yes") -        print("No") +        li = list(d.items()) +        d2 = dict() +        for cs in li: +            c1 = cs[0] +            c2 = cs[1] +            if c2 not in d2: +                d2[c2] = c1 +            else: +                if d2[c2] != c1: +                    print("No") +                    break +        else: +            print("Yes")