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.
import math
import sys


def I(): return int(input())


def II(): return map(int, sys.stdin.readline().rstrip().split())


def IL(): return list(map(int, input().split()))


def SIL(): return sorted(map(int, input().split()))


def RSIL(): return sorted(map(int, input().split()), reverse=True)


from collections import defaultdict
from collections import Counter
from collections import deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, _heapify_max, nlargest, nsmallest
import copy
from bisect import bisect_right


# sys.setrecursionlimit(2500)

mem = defaultdict(bool)
def equivalent(string1, string2):
    if (string1, string2) in mem:
        return mem[string1, string2]

    length = len(string1)
    if length == 1: return string1 == string2
    if length % 2 == 1:
        return string1 == string2

    half = length // 2
    a1, a2 = string1[:half], string1[half:]
    b1, b2 = string2[:half], string2[half:]

    if (a1 == b1 and a2 == b2) or (a1 == b2 and a2 == b1):
        mem[(string1, string2)] = True
        mem[(string2, string1)] = True
        return True

    one = equivalent(a1, b1)
    two = equivalent(a1, b2)
    three = equivalent(a2, b1)
    four = equivalent(a2, b2)


    answer = (one and four) or (two and three)
    mem[(string1, string2)] = answer
    mem[(string2, string1)] = answer
    return mem[(string1, string2)]


def solve():
   string1 = input()
   string2 = input()

   answer = equivalent(string1, string2)

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




T = 1
for ___ in range(T):
    solve()