inputS = input()
arrayS = list(inputS)
arraySorted = list(inputS)
arraySorted.sort()
inputT = input()
arrayT = list(inputT)
arrayTSorted = list(inputT)
arrayTSorted.sort()

flagForA =0
# the same character search
index = 0
length = len(arrayS)
listForSame = []
while index < length-1:
    if arraySorted[index] == arraySorted[index+1]:
        if arraySorted[index] in listForSame:
            pass
        else:
            listForSame.append(arraySorted[index])
    index+=1
if listForSame == []:
    flagForA=1
else:
    flag =0
    listForSet =[]
    for caburi in listForSame:
        index2 =0
        listForAdd = []
        while index2 < length:
            if arrayS[index2] == caburi:
                listForAdd.append(index2)
            index2+=1
        listForSet.append(listForAdd)
    for everySet in listForSet:
        index3 =0
        while index3 < len(everySet)-1:
            if arrayT[everySet[index3]] == arrayT[everySet[index3+1]]:
                index3+=1
            else:
                flag =1
                flagForA=0
                break
    if flag ==0:
        flagForA=1
    else:
        flagForA=0

flagForB =0           
# the same character searchT
index = 0
length = len(arrayT)
listForSame2 = []
while index < length-1:
    if arrayTSorted[index] == arrayTSorted[index+1]:
        if arrayTSorted[index] in listForSame2:
            pass
        else:
            listForSame2.append(arrayTSorted[index])
    index+=1
if listForSame2 == []:
    flagForB=1
else:
    flag =0
    listForSet =[]
    for caburi in listForSame2:
        index2 =0
        listForAdd = []
        while index2 < length:
            if arrayT[index2] == caburi:
                listForAdd.append(index2)
            index2+=1
        listForSet.append(listForAdd)
    for everySet in listForSet:
        index3 =0
        while index3 < len(everySet)-1:
            if arrayS[everySet[index3]] == arrayS[everySet[index3+1]]:
                index3+=1
            else:
                flag =1
                flagForB=0
                break
    if flag ==0:
        flagForB=1
    else:
        flagForB=0

#all character used search
allUsedFlagS =0
allUsedFlagT =0
flagForC =1
if length > 25:
    for char in [chr(i) for i in range(97,97+26)]:
        if char in arraySorted:
            pass
        else:
            allUsedFlagS =1
            break
    for char in [chr(i) for i in range(97,97+26)]:
        if char in arrayTSorted:
            pass
        else:
            allUsedFlagT =1
            break
    if allUsedFlagS ==0 and allUsedFlagT ==0:
        alphaList = [chr(i) for i in range(97,97+26)]
        sosuuList = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103]
        numberS =1
        for char1 in arrayS:
            index1 = alphaList.index(char1)
            numberS*= sosuuList[index1]
        numberT =1
        for char2 in arrayT:
            index2 = alphaList.index(char2)
            numberT*= sosuuList[index2]
        if numberS!=numberT:
            flagForC=0
        else:
            flagForC=1

        
if flagForA ==1 and flagForB==1 and flagForC==1:
    print("Yes")  
else:
    print("No")


Measured memory_bytes: 21976