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 sys
from bisect import bisect_left,bisect_right
from collections import defaultdict as dd
from collections import deque, Counter
from heapq import heappop,heappush,heapify,merge
from itertools import permutations, accumulate, product
from math import gcd,sqrt,ceil
toBin=lambda x:bin(x).replace("0b","")
inf=float("inf");DIRS=[[1,0],[-1,0],[0,1],[0,-1]];CHARS="abcdefghijklmnopqrstuvwxyz";MOD=10**9+7
###### Fill out N to calculate combinations#####################
# N=300010;fac=[1]*N;invfac=[1]*N
# for i in range(2,N):fac[i]=fac[i-1]*i%MOD
# invfac[N-1]=pow(fac[N-1],MOD-2,MOD)
# for i in range(N-1)[::-1]:invfac[i]=invfac[i+1]*(i+1)%MOD
# def c(i,j):return 0 if i<j else fac[i]*invfac[j]*invfac[i-j]
###############################################################
input=sys.stdin.readline

class UnionFind:
    def __init__(self,n):self.p=list(range(n));self.rank=[1]*n
    def find(self,x):
        if x!=self.p[x]:self.p[x]=self.find(self.p[x])
        return self.p[x]
    def union(self,x, y):
        px,py=self.find(x),self.find(y)
        if px==py:return 0
        self.p[py]=px
        return 1

from types import GeneratorType
def cache(f,queue=[]):
    def wrappedfunc(*args,**kwargs):
        if queue:return f(*args, **kwargs)
        else:
            to = f(*args,**kwargs)
            while True:
                if isinstance(to,GeneratorType):queue.append(to);to = next(to)
                else:
                    if not queue:break
                    queue.pop()
                    if not queue:break
                    to=queue[-1].send(to)
            return to
    return wrappedfunc

def query(x):
    print("? ",x,flush=True)
    return int(input())

sys.setrecursionlimit(200000)

# DP,BS,Greedy,Graph
def solve():
    """
    if odd, they have to be equal.
    if even, split them by their halves always. Recursively break it down.
    a,b,c,d
    a--------bc--------d
    f(a,b,a,b) and f(c,d,c,d)
    """
    @cache
    def f(i,j,k,l):
        # print(i,j,k,l)
        if i==j and k==l:return A[i]==B[k]
        s1=i;e1=i+(j-i)//2;s2=k;e2=k+(l-k)//2
        x=f(s1,e1,s2,e2) and f(e1+1,j,e2+1,l)
        y=f(s1,e1,e2+1,l) and f(e1+1,j,s2,e2)
        # print(x,y,i,j,k,l)
        return x or y
    A=str(input()).strip();B=str(input()).strip()
    if len(A)%2 and len(B)%2 and A==B:print("YES")
    elif len(A)%2 or len(B)%2:print("NO")
    else:print("YES" if f(0,len(A)-1,0,len(B)-1) else "NO")

if __name__=="__main__":
    solve()
