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.
try:
        import sys
        from functools import lru_cache, cmp_to_key
        from heapq import merge, heapify, heappop, heappush
        # from math import *
        from collections import defaultdict as dd, deque, Counter as C
        from itertools import combinations as comb, permutations as perm
        from bisect import bisect_left as bl, bisect_right as br, bisect, insort
        from time import perf_counter
        from fractions import Fraction
        import copy
        from copy import deepcopy
        import time
        starttime = time.time()
        mod = int(pow(10, 9) + 7)
        mod2 = 998244353

        def data(): return sys.stdin.readline().strip()
        def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
        def L(): return list(sp())
        def sl(): return list(ssp())
        def sp(): return map(int, data().split())
        def ssp(): return map(str, data().split())
        def l1d(n, val=0): return [val for i in range(n)]
        def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
        def A2(n,m): return [[0]*m for i in range(n)]
        def A(n):return [0]*n
        # sys.setrecursionlimit(int(pow(10,6)))
        # from sys import stdin
        # input = stdin.buffer.readline
        # I = lambda : list(map(int,input().split()))
        # import sys
        # input=sys.stdin.readline
        import math
        import string

        sys.stdin = open("input.txt", "r")
        sys.stdout = open("output.txt", "w")
except:
        pass

def compute_hash( s ):

        """
                This will work work string consisting of only lower characters
                If you want to do it for 
                        - only upper characters: change ord("a") to ord("A")
                        - both lower and upper: change p to 53
        """

        p = 31
        mod = 10**9 + 7
        hash_value = 0
        p_pow = 1
        H = [0]
        for c in s:
                hash_value = ( hash_value + ( ord(c) - ord("a") + 1) * p_pow ) % mod
                p_pow = ( p_pow * p ) % mod
                H.append(hash_value)

        return H
a = input()
b = input()


Ha = compute_hash(a)
Hb = compute_hash(b)

n = len(a)
def rec(al,ar,bl,br):

        if ar-al!=br-bl:
                return False

        hash_a = ((Ha[ar] - Ha[al-1])*pow(pow(31,al-1,mod),mod-2,mod))%mod
        hash_b = ((Hb[br] - Hb[bl-1])*pow(pow(31,bl-1,mod),mod-2,mod))%mod

        if hash_a == hash_b:
                return True
        if (ar-al+1)%2:
                return False
        mid = (ar-al+1)//2
        
        ans = ( rec(al,al+mid-1,bl,bl+mid-1) & rec(al+mid,ar,bl+mid,br) ) | ( rec(al,al+mid-1,bl+mid,br) & rec(al+mid,ar,bl,bl+mid-1) )
        # print(al, ar, bl, br, ans, hash_a, hash_b)
        return ans

if rec(1,n,1,n):
        print("YES")
else:
        print("NO")
