Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings *a* and *b* of equal length are called equivalent in one of the two cases: 
 1.  They are equal. 1.  If we split string *a* into two halves of the same size *a*<sub class="lower-index">1</sub> and *a*<sub class="lower-index">2</sub>, and string *b* into two halves of the same size *b*<sub class="lower-index">1</sub> and *b*<sub class="lower-index">2</sub>, then one of the following is correct: <ol> <li> *a*<sub class="lower-index">1</sub> is equivalent to *b*<sub class="lower-index">1</sub>, and *a*<sub class="lower-index">2</sub> is equivalent to *b*<sub class="lower-index">2</sub> 1.  *a*<sub class="lower-index">1</sub> is equivalent to *b*<sub class="lower-index">2</sub>, and *a*<sub class="lower-index">2</sub> is equivalent to *b*<sub class="lower-index">1</sub> 
As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.

Gerald has already completed this home task. Now it's your turn!
The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length.
#tle
##def dnccompare(a,b):
##    if a == b:
##        return 1
##    if len(a) % 2 == 0:
##        mid = int(len(a)/2)
##        a1 = a[:mid]
##        a2 = a[mid:]
##        b1 = b[:mid]
##        b2 = b[mid:]
##        a = min(a1,a2)+max(a1,a2)
##        b = min(b1,b2)+max(b1,b2)
##        if a == b:
##            return 1
##        else:
####            cek1 = dnccompare(a1,b2) and dnccompare(a2,b1)
####            cek2 = dnccompare(a1,b1) and dnccompare(a2,b2)
##            return dnccompare(min(a1,a2),min(b1,b2)) and dnccompare(max(a1,a2),max(b1,b2))
##    else:
####        if a == b:
####            return 1
####        else:
##            return 0
#inti fungsi berikut sama seperti merge sort, tetapi perbedaanya terletak pada saat conquer
#jika merge sort akan membandingkan masing-masing elemen, fungsi ini hanya melihat keseluruhannya
#contoh: aa dan ab, dia hanya melihat apakah aa < ab sebelum di-conquer dan jika iya akan di-conquer menjadi aaab
def dnc(a):
    if len(a) % 2 == 0: #hanya akan di-divide jika bisa dibagi menjadi 2 bagian yang sama panjangnya
        mid = int(len(a)/2) #proses divide berdasarkan titik tengah
        a1 = dnc(a[:mid])
        a2 = dnc(a[mid:])
        return min(a1,a2) + max(a1,a2)
    else:
        return a
#fungsi ini digunakan agar pada saat perbandingan tidak perlu membandingkan kiri dengan kiri atau kiri dengan kanan
#akan selalu membandingkan keseluruhan kata karena sudah di sort

a = str(input())
b = str(input())

cek = 0 #inisialisasi untuk pengecekan

if a == b:
    cek = 1
elif dnc(a) == dnc(b): #membandingkan kata setelah di-sort
    cek = 1

if cek:
    print("YES")
else:
    print("NO")