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:   They are equal.  If we split string a into two halves of the same size a_1 and a_2, and string b into two halves of the same size b_1 and b_2, then one of the following is correct:   a_1 is equivalent to b_1, and a_2 is equivalent to b_2  a_1 is equivalent to b_2, and a_2 is equivalent to b_1  

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!


-----Input-----

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.


-----Output-----

Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.


-----Examples-----
Input
aaba
abaa

Output
YES

Input
aabb
abab

Output
NO



-----Note-----

In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".

In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".

Difficulty: MEDIUM_HARD
Tags: String algorithms

Sorting

Divide and conquer
Skill types: Sorting

Starter code:

Solutions:
a = input()
b = input()

def half_str(s):
	return (s[:len(s) // 2], s[len(s) // 2:])

def compare(a, b):
	if a == b:
		return True
	elif len(a) % 2 == 1:
		return False
	else:
		(a1, a2) = half_str(a)
		(b1, b2) = half_str(b)
		return compare(a1, b2) and compare(a2, b1) or (compare(a1, b1) and compare(a2, b2))

def solve(a, b):
	equivalent = compare(a, b)
	if equivalent:
		print('YES')
	else:
		print('NO')
solve(a, b)


a = input()
b = input()

def iguais(a, b):
	if a == b:
		return True
	if len(a) % 2 != 0:
		return False
	a1 = a[0:len(a) // 2]
	a2 = a[len(a) // 2:len(a)]
	b1 = b[0:len(b) // 2]
	b2 = b[len(b) // 2:len(b)]
	if a1 == b2 and a2 == b1 or (a1 == b1 and a2 == b2):
		return True
	else:
		return iguais(a1, b2) and iguais(a2, b1) or (iguais(a1, b1) and iguais(a2, b2))
if iguais(a, b):
	print('YES')
else:
	print('NO')


def rec(str):
	n = len(str)
	if n % 2 == 1:
		return str
	n //= 2
	a = rec(str[:n])
	b = rec(str[n:])
	return a + b if a < b else b + a
(a, b) = (input(), input())
print('YES' if rec(a) == rec(b) else 'NO')


def canon(s):
	n = len(s)
	if n % 2:
		return s
	a = canon(s[:n // 2])
	b = canon(s[n // 2:])
	return a + b if a < b else b + a
a = canon(input())
b = canon(input())
print('YES' if a == b else 'NO')


def getLeastString(s):
	if len(s) & 1 != 0:
		return s
	x = getLeastString(s[:len(s) // 2])
	y = getLeastString(s[len(s) // 2:])
	return min(x + y, y + x)

def isEquivalent(a, b):
	return getLeastString(a) == getLeastString(b)
a = input()
b = input()
print('YES' if isEquivalent(a, b) else 'NO')


import sys
from collections import Counter
(a, b) = (input(), input())
sys.setrecursionlimit(100)

def solve(a, b):

	def is_eq(l, a, b):
		if a == b:
			return True
		if l % 2 == 1:
			return a == b
		l //= 2
		(a1, a2) = (a[:l], a[l:])
		(b1, b2) = (b[:l], b[l:])
		return is_eq(l, a1, b1) and is_eq(l, a2, b2) or (is_eq(l, a1, b2) and is_eq(l, a2, b1))
	l = len(a)
	if Counter(a) != Counter(b):
		return False
	return is_eq(l, a, b)
print('YES' if solve(a, b) else 'NO')


def func(string):
	tamanho = len(string)
	if tamanho % 2 == 1:
		return string
	else:
		tamanho = tamanho // 2
		string1 = func(string[:tamanho])
		string2 = func(string[tamanho:])
		if string1 < string2:
			return string1 + string2
		else:
			return string2 + string1
a = input()
b = input()
if func(a) == func(b):
	print('YES')
else:
	print('NO')


print((lambda a, b: 'YES' if (lambda f: lambda x: f(f, x))(lambda f, x: x if len(x) % 2 == 1 else (lambda a, b: a + b if a < b else b + a)(f(f, x[:len(x) >> 1]), f(f, x[len(x) >> 1:])))(a) == (lambda f: lambda x: f(f, x))(lambda f, x: x if len(x) % 2 == 1 else (lambda a, b: a + b if a < b else b + a)(f(f, x[:len(x) >> 1]), f(f, x[len(x) >> 1:])))(b) else 'NO')(input(), input()))


a = input()
b = input()

def equal(x: str, y: str):
	length = len(x)
	if x == y:
		return True
	elif length % 2 == 0:
		length = int(length / 2)
		if equal(x[:length], y[length:]) and equal(x[length:], y[:length]):
			return True
		else:
			return equal(x[:length], y[:length]) and equal(x[length:], y[length:])
	else:
		return False
if equal(a, b):
	print('YES')
else:
	print('NO')


def check(s):
	l = len(s)
	if l % 2:
		return s
	lef = check(s[:l // 2])
	rig = check(s[l // 2:])
	ans = lef + rig if lef > rig else rig + lef
	return ans
s = input()
s2 = input()
s_2 = check(s)
s2_2 = check(s2)
if s_2 == s2_2:
	print('YES')
else:
	print('NO')


def equivalent(string):
	n = len(string)
	if n % 2:
		return string
	n = int(n / 2)
	(s1, s2) = (equivalent(string[:-n]), equivalent(string[n:]))
	if s1 > s2:
		return s1 + s2
	else:
		return s2 + s1
(a, b) = (input(), input())
if equivalent(a) == equivalent(b):
	print('YES')
else:
	print('NO')


def divide_letras(palavra):
	tamanhoPalavra = len(palavra)
	if tamanhoPalavra % 2 == 1:
		return palavra
	tamanhoPalavra = tamanhoPalavra // 2
	esquerda = divide_letras(palavra[:tamanhoPalavra])
	direita = divide_letras(palavra[tamanhoPalavra:])
	if direita > esquerda:
		return direita + esquerda
	else:
		return esquerda + direita

def stringsEquivalentes(palavraA, palavraB):
	if divide_letras(palavraA) == divide_letras(palavraB):
		print('YES')
	else:
		print('NO')
palavraA = input()
palavraB = input()
stringsEquivalentes(palavraA, palavraB)


def eq(a, b):
	if a == b:
		return True
	if len(a) % 2 == 1:
		return False
	l = int(len(a) / 2)
	if eq(a[:l], b[l:]) and eq(a[l:], b[:l]):
		return True
	elif eq(a[:l], b[:l]) and eq(a[l:], b[l:]):
		return True
	else:
		return False
a = list(input())
b = list(input())
if eq(a, b):
	print('YES')
else:
	print('NO')


import sys, math, queue
MOD = 10 ** 9 + 7
a = input()
b = input()

def equivalent(a, b, ss1, se1, ss2, se2):
	equal = True
	for i in range(se1 - ss1 + 1):
		if a[ss1 + i] != b[ss2 + i]:
			equal = False
			break
	if equal:
		return True
	if se1 - ss1 + 1 & 1 == 1:
		return False
	sm1 = ss1 - 1 + (se1 - ss1 + 1) // 2
	sm2 = ss2 - 1 + (se2 - ss2 + 1) // 2
	if equivalent(a, b, ss1, sm1, sm2 + 1, se2) and equivalent(a, b, sm1 + 1, se1, ss2, sm2):
		return True
	return equivalent(a, b, ss1, sm1, ss2, sm2) and equivalent(a, b, sm1 + 1, se1, sm2 + 1, se2)
print('YES' if equivalent(a, b, 0, len(a) - 1, 0, len(a) - 1) else 'NO')


def check(str):
	if len(str) % 2 != 0:
		return str
	return sorted([check(str[:len(str) // 2]), check(str[len(str) // 2:])])
a = input()
b = input()
if check(a) == check(b):
	print('YES')
else:
	print('NO')


def sol(s1, s2):
	l = len(s1)
	if s1 == s2:
		return True
	if l % 2 == 0 and (sol(s1[:l // 2], s2[l // 2:]) and sol(s2[:l // 2], s1[l // 2:]) or (sol(s1[:l // 2], s2[:l // 2]) and sol(s1[l // 2:], s2[l // 2:]))):
		return True
	return False
a = input().strip()
b = input().strip()
if sol(a, b):
	print('YES')
else:
	print('NO')


import math

def menor(palavra):
	if len(palavra) % 2 == 1:
		return palavra
	a = menor(palavra[0:math.ceil(len(palavra) / 2)])
	b = menor(palavra[math.ceil(len(palavra) / 2):len(palavra)])
	if a < b:
		return a + b
	else:
		return b + a
palavra1 = input()
palavra2 = input()
if menor(palavra1) == menor(palavra2):
	print('YES')
else:
	print('NO')


(a, b) = (list(input()), list(input()))
n = len(a)
(chunk_size, count) = (n, 0)
while not chunk_size & 1:
	chunk_size >>= 1
	count += 1
for _ in range(count):
	new_chunk_size = chunk_size << 1
	for i in range(0, n, new_chunk_size):
		start = i
		mid = start + chunk_size
		end = min(i + new_chunk_size, n)
		(a_part1, a_part2) = (a[start:mid], a[mid:end])
		(b_part1, b_part2) = (b[start:mid], b[mid:end])
		if a_part1 > a_part2:
			(a[start:mid], a[mid:end]) = (a_part2, a_part1)
		if b_part1 > b_part2:
			(b[start:mid], b[mid:end]) = (b_part2, b_part1)
	chunk_size = new_chunk_size
print('YES' if a == b else 'NO')


first_string = input()
second_string = input()

def prepare_string(s):
	if len(s) % 2 != 0:
		return s
	str1 = prepare_string(s[0:int(len(s) / 2)])
	str2 = prepare_string(s[int(len(s) / 2):len(s)])
	if str1 < str2:
		return str1 + str2
	else:
		return str2 + str1
if prepare_string(first_string) == prepare_string(second_string):
	print('YES')
else:
	print('NO')


def getString(s, n):
	if n % 2 != 0:
		return s
	firstPart = getString(s[:n // 2], n // 2)
	lastPart = getString(s[n // 2:], n // 2)
	if firstPart > lastPart:
		return lastPart + firstPart
	return firstPart + lastPart
s1 = input()
s2 = input()
n = len(s1)
s_1 = getString(s1, n)
s_2 = getString(s2, n)
if s_1 == s_2:
	print('YES')
else:
	print('NO')


def EquivalentStrings(a, b):
	if a == b:
		return True
	if len(a) % 2 != 0:
		return a == b
	halve_len = int(len(a) / 2)
	a1 = a[:halve_len]
	a2 = a[halve_len:]
	b1 = b[:halve_len]
	b2 = b[halve_len:]
	if EquivalentStrings(a1, b2) and EquivalentStrings(a2, b1):
		return True
	if EquivalentStrings(a1, b1) and EquivalentStrings(a2, b2):
		return True
	return False
a = input()
b = input()
if EquivalentStrings(a, b):
	print('YES')
else:
	print('NO')


def rEqual(a, b, al, bl):
	if a == b:
		return True
	elif al % 2 == 0 and bl % 2 == 0:
		t = rEqual(a[:al // 2], b[bl // 2:], al // 2, bl // 2) and rEqual(a[al // 2:], b[:bl // 2], al // 2, bl // 2) or (rEqual(a[al // 2:], b[bl // 2:], al // 2, bl // 2) and rEqual(a[:al // 2], b[:bl // 2], al // 2, bl // 2))
		return t
	else:
		return False
s1 = input().split()[0]
s2 = input().split()[0]
t = rEqual(s1, s2, len(s1), len(s2))
if t:
	print('YES')
else:
	print('NO')


def sort(string, lenString):
	if lenString % 2 != 0:
		return string
	half = lenString // 2
	stringOne = sort(string[:half], half)
	stringTwo = sort(string[half:], half)
	if stringOne > stringTwo:
		return stringTwo + stringOne
	else:
		return stringOne + stringTwo
string_one = input()
string_two = input()
lenString = len(string_one)
if sort(string_one, lenString) == sort(string_two, lenString):
	print('YES')
else:
	print('NO')


x = str(input())
y = str(input())

def e(a, b):
	if len(a) % 2 == 1:
		if a == b:
			return True
		else:
			return False
	x = len(a) // 2
	if e(a[:x], b[:x]) and e(a[x:], b[x:]):
		return True
	if e(a[x:], b[:x]) and e(a[:x], b[x:]):
		return True
	return False
if e(x, y):
	print('YES')
else:
	print('NO')


def equivalent(a, b):
	if len(a) % 2 != 0:
		return a == b
	if a == b:
		return True
	l = len(a) // 2
	a1 = a[:l]
	a2 = a[l:]
	b1 = b[:l]
	b2 = b[l:]
	if equivalent(a1, b2) and equivalent(a2, b1):
		return True
	if equivalent(a1, b1) and equivalent(a2, b2):
		return True
	return False
a = input()
b = input()
if equivalent(a, b):
	print('YES')
else:
	print('NO')


def parte(s):
	if len(s) % 2:
		return s
	else:
		m1 = parte(s[:len(s) // 2])
		m2 = parte(s[len(s) // 2:])
	return m1 + m2 if m1 < m2 else m2 + m1
a = input()
b = input()
if parte(a) == parte(b):
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def smallest(s):
	n = len(s)
	if n % 2 == 1:
		return s
	else:
		s1 = smallest(s[0:n // 2])
		s2 = smallest(s[n // 2:n])
		if s1 < s2:
			return s1 + s2
		else:
			return s2 + s1
a = input()
b = input()
if smallest(a) == smallest(b):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def equivalent(a, b):
	half = int(len(a) / 2)
	if a == b:
		return True
	if len(a) % 2 == 1:
		return False
	return equivalent(a[half:], b[:half]) and equivalent(a[:half], b[half:]) or (equivalent(a[half:], b[half:]) and equivalent(a[:half], b[:half]))
print('YES' if equivalent(a, b) else 'NO')


def g(s):
	l = len(s)
	return sorted([g(s[:l // 2]), g(s[l // 2:])]) if l % 2 == 0 else s
i = input
print('YES' if g(i()) == g(i()) else 'NO')


s1 = input()
s2 = input()

def is_less(s):
	if len(s) % 2 == 1:
		return s
	l = is_less(s[:len(s) // 2])
	r = is_less(s[len(s) // 2:])
	return l + r if l < r else r + l
if is_less(s1) == is_less(s2):
	print('YES')
else:
	print('NO')


a = input().strip()
b = input().strip()

def check(xa, ya, xb, yb):
	if (ya - xa) % 2:
		return True if a[xa:ya] == b[xb:yb] else False
	elif a[xa:ya] == b[xb:yb]:
		return True
	else:
		mida = (ya + xa) // 2
		midb = (yb + xb) // 2
		if check(xa, mida, xb, midb) and check(mida, ya, midb, yb):
			return True
		if check(mida, ya, xb, midb) and check(xa, mida, midb, yb):
			return True
		return False
print('YES' if check(0, len(a), 0, len(b)) else 'NO')


import sys
import functools

@functools.lru_cache(None)
def func(a, b):
	if a == b:
		return True
	elif len(a) % 2 != 0:
		return False
	elif func(a[:int(len(a) / 2)], b[:int(len(b) / 2)]) and func(a[int(len(a) / 2):], b[int(len(b) / 2):]):
		return True
	elif func(a[int(len(a) / 2):], b[:int(len(b) / 2)]) and func(a[:int(len(a) / 2)], b[int(len(b) / 2):]):
		return True
	return False
first = sys.stdin.readline().rstrip()
second = sys.stdin.readline().rstrip()
if func(first, second):
	print('YES')
else:
	print('NO')


def smallest(x):
	if len(x) % 2:
		return x
	s1 = smallest(x[:len(x) // 2])
	s2 = smallest(x[len(x) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1

def are_equiv(x, y):
	if smallest(x) == smallest(y):
		print('YES')
	else:
		print('NO')
s1 = input()
s2 = input()
are_equiv(s1, s2)


def equal(a, b):
	l = len(a)
	if a == b:
		return True
	elif l % 2 == 1:
		return False
	l = l // 2
	return equal(a[:l], b[l:]) and equal(a[l:], b[:l]) or (equal(a[:l], b[:l]) and equal(a[l:], b[l:]))
a = input()
b = input()
print('YES' if equal(a, b) else 'NO')


def equivalente(a, b):
	tam = len(a)
	x = tam // 2
	if a == b:
		return True
	if tam % 2 != 0:
		return False
	a1 = a[:x]
	a2 = a[x:]
	b1 = b[:x]
	b2 = b[x:]
	return equivalente(a1, b1) and equivalente(a2, b2) or (equivalente(a1, b2) and equivalente(a2, b1))
string1 = input()
string2 = input()
if sorted(string1) == sorted(string2):
	print('YES' if equivalente(string1, string2) else 'NO')
else:
	print('NO')


def eq(stra, strb):
	if stra == strb:
		return True
	size = len(stra)
	if size % 2:
		return False
	n = size // 2
	stra_1 = stra[:n]
	stra_2 = stra[n:]
	strb_1 = strb[:n]
	strb_2 = strb[n:]
	return eq(stra_1, strb_2) and eq(strb_1, stra_2) or (eq(stra_1, strb_1) and eq(strb_2, stra_2))
stra = input()
strb = input()
if eq(stra, strb):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def acomodoStrings(s):
	separacion = len(s)
	if separacion % 2 == 1:
		return s
	separacion //= 2
	ac = acomodoStrings(s[0:separacion])
	bc = acomodoStrings(s[separacion:])
	orden1 = ac + bc
	orden2 = bc + ac
	return orden1 if ac < bc else orden2
print('YES' if acomodoStrings(a) == acomodoStrings(b) else 'NO')


firstString = input()
secondString = input()

def sortedStr(word):
	if len(word) % 2 == 1:
		return word
	mid = int(len(word) / 2)
	left = sortedStr(word[mid:])
	right = sortedStr(word[:mid])
	if left > right:
		return right + left
	else:
		return left + right
valid = sortedStr(firstString) == sortedStr(secondString)
print('YES' if valid else 'NO')


a_str = input()
b_str = input()

def smallest(a_str):
	if len(a_str) % 2 == 1:
		return a_str
	s1 = smallest(a_str[0:int(len(a_str) / 2)])
	s2 = smallest(a_str[int(len(a_str) / 2):len(a_str)])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
ans = smallest(a_str) == smallest(b_str)
if ans:
	print('YES')
else:
	print('NO')


def divid(s):
	n = len(s)
	if n % 2:
		return s
	n = int(n / 2)
	s1 = divid(s[:-n])
	s2 = divid(s[n:])
	if s1 > s2:
		return s1 + s2
	else:
		return s2 + s1
a = input()
b = input()
if divid(a) == divid(b):
	print('YES')
else:
	print('NO')


def canonical(s):
	n = len(s)
	if n % 2 == 1:
		return s
	x = canonical(s[:n // 2])
	y = canonical(s[n // 2:])
	return x + y if x < y else y + x
s = input()
t = input()
print('YES' if canonical(s) == canonical(t) else 'NO')


def equivalente(s):
	if len(s) % 2:
		return s
	a = equivalente(s[:len(s) // 2])
	b = equivalente(s[len(s) // 2:])
	return a + b if a < b else b + a
print('YES' if equivalente(input()) == equivalente(input()) else 'NO')


def leastLexiString(s):
	if len(s) & 1 != 0:
		return s
	x = leastLexiString(s[0:int(len(s) / 2)])
	y = leastLexiString(s[int(len(s) / 2):len(s)])
	return min(x + y, y + x)

def areEquivalent(a, b):
	return leastLexiString(a) == leastLexiString(b)
a = input()
b = input()
if areEquivalent(a, b):
	print('YES')
else:
	print('NO')


def equal(s):
	if len(s) & 1:
		return s
	mid = len(s) // 2
	a = equal(s[:mid])
	b = equal(s[mid:])
	if a < b:
		return a + b
	else:
		return b + a
a = input()
b = input()
if equal(a) == equal(b):
	print('YES')
else:
	print('NO')


def equivalent_strings(string):
	if len(string) % 2 != 0:
		return string
	n = len(string) // 2
	(s1, s2) = (equivalent_strings(string[:n]), equivalent_strings(string[n:]))
	if s1 > s2:
		return s1 + s2
	else:
		return s2 + s1
string_a = input()
string_b = input()
print('YES' if equivalent_strings(string_a) == equivalent_strings(string_b) else 'NO')


def smallest(s):
	s_len = len(s)
	if s_len % 2 == 1:
		return s
	s1 = smallest(s[0:s_len // 2])
	s2 = smallest(s[s_len // 2:s_len])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
first = str(input())
second = str(input())
res_1 = smallest(first)
res_2 = smallest(second)
if res_1 == res_2:
	print('YES')
else:
	print('NO')


A = input()
B = input()

def smallest(strng):
	if len(strng) % 2 == 1:
		return strng
	s1 = smallest(strng[0:len(strng) // 2])
	s2 = smallest(strng[len(strng) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if smallest(A) == smallest(B):
	print('YES')
else:
	print('NO')


from functools import lru_cache

@lru_cache(maxsize=5)
def solve2(s, l):
	if l % 2:
		return s
	mid = l // 2
	s1 = solve2(s[:mid], mid)
	s2 = solve2(s[mid:], mid)
	return s1 + s2 if s1 < s2 else s2 + s1

def solution():
	s1 = input()
	s2 = input()
	n = len(s1)
	res1 = solve2(s1, n)
	res2 = solve2(s2, n)
	if res1 == res2:
		print('YES')
	else:
		print('NO')
solution()


def function(s):
	lens = len(s)
	if lens % 2:
		return s
	return sorted([function(s[:lens // 2]), function(s[lens // 2:])])
if function(input()) == function(input()):
	print('YES')
else:
	print('NO')


def reorganizeStr(string):
	if len(string) % 2 == 1:
		return string
	mid = len(string) // 2
	part1 = reorganizeStr(string[:mid])
	part2 = reorganizeStr(string[mid:])
	if part1 < part2:
		return part1 + part2
	return part2 + part1

def isEquivalent(a, b, tam):
	a = reorganizeStr(a)
	b = reorganizeStr(b)
	return a == b

def run():
	str1 = input()
	str2 = input()
	if isEquivalent(str1, str2, len(str1)):
		print('YES')
	else:
		print('NO')
run()


s1 = input()
s2 = input()

def check(a1, a2):
	if a1 == a2:
		return 1
	n = len(a1)
	if n == 1:
		if a1 == a2:
			return 1
		else:
			return 0
	if n % 2 != 0:
		return 0
	mid = int(n / 2)
	if check(a1[:mid], a2[mid:]) and check(a2[:mid], a1[mid:]):
		return 1
	if check(a1[:mid], a2[:mid]) and check(a2[mid:], a1[mid:]):
		return 1
	return 0
if check(s1, s2):
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def equiv(S):
	if len(S) % 2 == 1:
		return S
	S1 = equiv(S[:len(S) // 2])
	S2 = equiv(S[len(S) // 2:])
	return S1 + S2 if S1 < S2 else S2 + S1

def solve():
	(S, T) = (listStr(), listStr())
	return 'YES' if equiv(S) == equiv(T) else 'NO'
print(solve())


word1 = input()
word2 = input()

def check(word):
	if len(word) % 2 != 0:
		return word
	half = int(len(word) / 2)
	first_half = check(word[:half])
	last_half = check(word[half:])
	if first_half < last_half:
		return first_half + last_half
	else:
		return last_half + first_half
if check(word1) == check(word2):
	print('YES')
else:
	print('NO')


def ifEqual(a, b):
	le = len(a)
	if a == b:
		return True
	elif le % 2 == 0 and (ifEqual(a[:le // 2], b[le // 2:]) and ifEqual(b[:le // 2], a[le // 2:]) or (ifEqual(a[:le // 2], b[:le // 2]) and ifEqual(b[le // 2:], a[le // 2:]))):
		return True
	else:
		return False
a = input()
b = input()
if ifEqual(a, b):
	print('YES')
else:
	print('NO')


def sm(s):
	if len(s) % 2 == 1:
		return s
	s1 = sm(s[:len(s) // 2])
	s2 = sm(s[len(s) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if sm(input()) == sm(input()):
	print('YES')
else:
	print('NO')


def equi(s):
	n = len(s)
	if n % 2 == 1:
		return s
	n = int(n / 2)
	(s1, s2) = (equi(s[:n]), equi(s[n:]))
	return s1 + s2 if s1 > s2 else s2 + s1

def main():
	(a, b) = (input(), input())
	result = 'YES' if equi(a) == equi(b) else 'NO'
	print(result)
main()


import os
import sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd, log
from collections import *
from bisect import *
from heapq import *
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
g = lambda : input().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(a, b) = (gcl(), gcl())

def comp(a, i, j):
	end = j
	while i < end and a[i] == a[j]:
		i += 1
		j += 1
	if i < end and a[i] > a[j]:
		while i < end:
			(a[i], a[j]) = (a[j], a[i])
			i += 1
			j += 1

def resolve(a, start, end):
	n = end - start + 1
	if n & 1:
		return
	mid = start + n // 2
	resolve(a, start, mid - 1)
	resolve(a, mid, end)
	comp(a, start, mid)
resolve(a, 0, len(a) - 1)
resolve(b, 0, len(a) - 1)
print('YES' if a == b else 'NO')


(a, b) = (input(), input())
if set(a) != set(b):
	print('NO')
	exit()

def is_eq(a, b):
	if a == b:
		return True
	elif len(a) == 1 or (len(a) % 2 != 0 and a != b):
		return False
	d = len(a) // 2
	return is_eq(a[:d], b[d:]) and is_eq(a[d:], b[:d]) or (is_eq(a[:d], b[:d]) and is_eq(a[d:], b[d:]))
print('YES' if is_eq(a, b) else 'NO')


def getmin(s):
	ls = len(s)
	if ls % 2 == 1:
		return s
	s1 = getmin(s[:ls // 2])
	s2 = getmin(s[ls // 2:])
	return s1 + s2 if s1 < s2 else s2 + s1
s1 = input()
s2 = input()
print('YES') if getmin(s1) == getmin(s2) else print('NO')


a = input()
b = input()
d = dict()

def split(s):
	b = len(s) // 2
	return (s[:b], s[b:])

def equal(a, b):
	if a == b:
		return True
	if len(a) % 2 != 0:
		return False
	if (a, b) in d:
		return d[a, b]
	(a1, a2) = split(a)
	(b1, b2) = split(b)
	if a1 == b2 and a2 == b1:
		return True
	if equal(a1, b2) and equal(a2, b1) or (equal(a1, b1) and equal(a2, b2)):
		d[a, b] = True
		return True
	d[a, b] = False
	return False
if equal(a, b):
	print('YES')
else:
	print('NO')


def equivalentStrings(string):
	if len(string) & 1:
		return string
	a = equivalentStrings(string[:len(string) >> 1])
	b = equivalentStrings(string[len(string) >> 1:])
	return a + b if a < b else b + a
print('YES' if equivalentStrings(input()) == equivalentStrings(input()) else 'NO')


def div(s):
	lenght = len(s)
	if lenght % 2 == 1:
		return s
	s1 = div(s[0:int(lenght / 2)])
	s2 = div(s[int(lenght / 2):lenght])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
s1 = input()
s2 = input()
print('YES') if div(s1) == div(s2) else print('NO')


s1 = input()
s2 = input()
lenn = len(s1)
if s1 == s2:
	print('YES')
elif lenn % 2 == 1 and lenn != 1:
	print('NO')
else:

	def calc(str1, str2):
		l = len(str1)
		if l == 1 or str1 == str2:
			if str1 == str2:
				return 1
			else:
				return 0
		if l % 2 == 1:
			return 0
		str11 = str1[0:l // 2]
		str12 = str1[l // 2:l]
		str21 = str2[:l // 2]
		str22 = str2[l // 2:l]
		if calc(str11, str22) and calc(str12, str21):
			return 1
		elif calc(str11, str21) and calc(str12, str22):
			return 1
		else:
			return 0
	if calc(s1, s2):
		print('YES')
	else:
		print('NO')


def equ(s):
	l = len(s)
	return sorted([equ(s[:l // 2]), equ(s[l // 2:])]) if l % 2 == 0 else s
print('YES' if equ(input()) == equ(input()) else 'NO')


def f(s):
	if len(s) % 2 == 1:
		return s
	a = f(s[:len(s) // 2])
	b = f(s[len(s) // 2:])
	if a < b:
		return a + b
	else:
		return b + a
string1 = input()
string2 = input()
if f(string1) == f(string2):
	print('YES')
else:
	print('NO')


def dividir(cadena):
	if len(cadena) % 2 == 1:
		return cadena
	a1 = dividir(cadena[:len(cadena) // 2])
	a2 = dividir(cadena[len(cadena) // 2:])
	if a1 > a2:
		return a2 + a1
	else:
		return a1 + a2

def main():
	a = input()
	b = input()
	respuesta = 'NO'
	if a == b:
		respuesta = 'YES'
	elif dividir(a) == dividir(b):
		respuesta = 'YES'
	print(respuesta)
main()


import sys

def is_equal(str1, str2, l):
	if str1 == str2:
		return True
	hl = int(l / 2)
	if l % 2 == 1:
		return str1 == str2
	else:
		a1 = str1[0:hl]
		b1 = str2[0:hl]
		a2 = str1[hl:l]
		b2 = str2[hl:l]
		if is_equal(a1, b2, hl) and is_equal(a2, b1, hl):
			return True
		else:
			return is_equal(a1, b1, hl) and is_equal(a2, b2, hl)
str1 = input()
str2 = input()
if is_equal(str1, str2, len(str1)):
	print('YES')
else:
	print('NO')


a = input('')
b = input('')

def findEqual(a):
	if len(a) % 2:
		return a
	a1 = findEqual(a[:len(a) // 2])
	a2 = findEqual(a[len(a) // 2:])
	if a1 < a2:
		return a1 + a2
	else:
		return a2 + a1
if findEqual(a) == findEqual(b):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def split(s):
	length = len(s)
	if length % 2 == 0:
		s1 = split(s[:int(length / 2)])
		s2 = split(s[int(length / 2):])
		if s1 < s2:
			return s1 + s2
		else:
			return s2 + s1
	else:
		return s
if split(a) == split(b):
	print('YES')
else:
	print('NO')


def arranged(s):
	n = len(s)
	if n & 1:
		return s
	s1 = arranged(s[0:n // 2])
	s2 = arranged(s[n // 2:n])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
a = input()
b = input()
print('YES') if arranged(a) == arranged(b) else print('NO')


def isEquivalent(a, b):
	size = len(a)
	if a == b:
		return True
	if size % 2 == 1:
		return False
	a1 = a[size // 2:]
	a2 = a[0:size // 2]
	b1 = b[size // 2:]
	b2 = b[0:size // 2]
	if size <= 2:
		return a1 == b1 and a2 == b2 or (a1 == b2 and a2 == b1)
	else:
		return isEquivalent(a1, b2) and isEquivalent(a2, b1) or (isEquivalent(a1, b1) and isEquivalent(a2, b2))
aa = input()
bb = input()
if isEquivalent(aa, bb):
	print('YES')
else:
	print('NO')


def isEquiv(s1, s2):
	if s1 == s2:
		return True
	if len(s1) % 2 != 0 or len(s2) % 2 != 0:
		return False
	else:
		mid = len(s1) // 2
		a1 = s1[:mid]
		a2 = s1[mid:]
		b1 = s2[mid:]
		b2 = s2[:mid]
		return isEquiv(a1, b1) and isEquiv(a2, b2) or (isEquiv(a1, b2) and isEquiv(a2, b1))
s1 = input()
s2 = input()
print('YES' if isEquiv(s1, s2) else 'NO')


def equal(a, b):
	half = int(len(a) / 2)
	a1 = a[half:]
	a2 = a[:half]
	b1 = b[half:]
	b2 = b[:half]
	if half % 2 == 1:
		return a1 == b1 and a2 == b2 or (a1 == b2 and a2 == b1)
	if a1 == b1 and a2 == b2 or (a1 == b2 and a2 == b1):
		return True
	else:
		return equal(a1, b1) and equal(a2, b2) or (equal(a1, b2) and equal(a2, b1))
a = input()
b = input()
if a == b:
	print('YES')
elif len(a) % 2 == 0:
	if equal(a, b):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys

def solve(a):
	sys.setrecursionlimit(sys.getrecursionlimit() + 1)
	if len(a) & 1:
		return a
	s1 = solve(a[:len(a) // 2])
	s2 = solve(a[len(a) // 2:])
	return s1 + s2 if s1 < s2 else s2 + s1
(a, b) = (input(), input())
print('YES' if solve(a) == solve(b) else 'NO')


def equivalent(string):
	if len(string) % 2 != 0:
		return string
	s1 = equivalent(string[len(string) // 2:])
	s2 = equivalent(string[:len(string) // 2])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
str_1 = input()
str_2 = input()
if equivalent(str_1) == equivalent(str_2):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def dividir(string):
	if len(string) % 2 != 0:
		return string
	return sorted([dividir(string[:len(string) // 2]), dividir(string[len(string) // 2:])])
if dividir(a) == dividir(b):
	print('YES')
else:
	print('NO')


def main():

	def f(s):
		if len(s) % 2 == 1:
			return s
		s1 = f(s[:len(s) // 2])
		s2 = f(s[len(s) // 2:])
		if s1 < s2:
			return s1 + s2
		return s2 + s1
	a = input()
	b = input()
	return 'YES' if f(a) == f(b) else 'NO'
print(main())


def rec(strA, strB):
	s = len(strA)
	half = int(len(strA) / 2)
	(a1, a2) = (strA[:half], strA[half:])
	(b1, b2) = (strB[:half], strB[half:])
	if strA == strB:
		return True
	elif s <= 1 or s % 2 == 1:
		return False
	elif rec(a1, b2) and rec(a2, b1):
		return True
	elif rec(a1, b1) and rec(a2, b2):
		return True
	else:
		return False
a = input()
b = input()
if rec(a, b):
	print('YES')
else:
	print('NO')


def splitWord(word):
	if len(word) % 2 != 0:
		return word
	middle = int(len(word) / 2)
	left = splitWord(word[:middle])
	right = splitWord(word[middle:])
	stringToRet = ''
	if left < right:
		stringToRet = left + right
	else:
		stringToRet = right + left
	return stringToRet
string1 = input()
word1 = splitWord(string1)
string2 = input()
word2 = splitWord(string2)
if word1 == word2:
	print('YES')
else:
	print('NO')


def checaEquavalencia(a, b, tam):
	if a == b:
		return True
	elif len(a) % 2 == 1:
		return False
	elif len(b) % 2 == 1:
		return False
	elif tam > 1:
		tam = tam // 2
		a1 = a[:tam]
		a2 = a[tam:]
		b1 = b[:tam]
		b2 = b[tam:]
		if checaEquavalencia(a1, b2, tam) and checaEquavalencia(a2, b1, tam):
			return True
		elif checaEquavalencia(a1, b1, tam) and checaEquavalencia(a2, b2, tam):
			return True
	return False
a = input()
b = input()
resposta = 'NO'
ta = len(a)
tb = len(b)
if ta != tb:
	resposta = 'NO'
elif a == b:
	resposta = 'YES'
elif ta % 2 == 0:
	resp = checaEquavalencia(a, b, ta)
	if resp == True:
		resposta = 'YES'
print(resposta)


def isEqual(a_total, b_total):
	if a_total == b_total:
		return True
	if len(a_total) != len(b_total):
		return False
	if len(a_total) % 2 == 1:
		return False
	half = len(a_total) // 2
	a_part1 = a_total[:half]
	b_part1 = b_total[:half]
	a_part2 = a_total[half:]
	b_part2 = b_total[half:]
	return isEqual(a_part1, b_part2) and isEqual(a_part2, b_part1) or (isEqual(a_part1, b_part1) and isEqual(a_part2, b_part2))
a_total = input()
b_total = input()
if isEqual(a_total, b_total):
	print('YES')
else:
	print('NO')


def pairSort(s):
	l = len(s)
	if l % 2:
		return s
	left = pairSort(s[:l // 2])
	right = pairSort(s[l // 2:])
	s = left + right if left > right else right + left
	return s
s = input().strip()
t = input().strip()
s = pairSort(s)
t = pairSort(t)
print('YES') if s == t else print('NO')


from sys import stdin, stdout, stderr

def splitStr(string):
	if len(string) % 2 == 1:
		return string
	left = splitStr(string[:len(string) // 2])
	right = splitStr(string[len(string) // 2:])
	if left + right < right + left:
		return left + right
	else:
		return right + left
stringa = stdin.readline()
stringb = stdin.readline()
stringa = stringa[:-1]
stringb = stringb[:-1]
stringa = splitStr(stringa)
stringb = splitStr(stringb)
if stringa == stringb:
	stdout.write('YES')
else:
	stdout.write('NO')


def dnc(a):
	if len(a) % 2 == 0:
		mid = int(len(a) / 2)
		a1 = dnc(a[:mid])
		a2 = dnc(a[mid:])
		return min(a1, a2) + max(a1, a2)
	else:
		return a
a = str(input())
b = str(input())
cek = 0
if a == b:
	cek = 1
elif dnc(a) == dnc(b):
	cek = 1
if cek:
	print('YES')
else:
	print('NO')


dp = {}

def equiv(a, b):
	if (a, b) in dp:
		return dp[a, b]
	if a == b:
		return True
	if len(a) % 2 == 1 or len(b) % 2 == 1:
		return False
	a1 = a[:len(a) // 2]
	a2 = a[len(a) // 2:]
	b1 = b[:len(b) // 2]
	b2 = b[len(b) // 2:]
	dp[a, b] = equiv(a1, b1) and equiv(a2, b2) or (equiv(a1, b2) and equiv(a2, b1))
	return dp[a, b]
a = input()
b = input()
if equiv(a, b):
	print('YES')
else:
	print('NO')


x = input()
y = input()

def substring(word):
	size = len(word)
	if size % 2 == 1:
		return word
	word_a = substring(word[0:int(size / 2)])
	word_b = substring(word[int(size / 2):size])
	if word_a < word_b:
		return word_a + word_b
	else:
		return word_b + word_a
if substring(x) == substring(y):
	print('YES')
else:
	print('NO')


def ordena(s):
	if len(s) % 2 == 1:
		return s
	t = int(len(s) / 2)
	s1 = ordena(s[:t])
	s2 = ordena(s[t:])
	if s2 > s1:
		return s1 + s2
	else:
		return s2 + s1
s1 = input()
s2 = input()
s1 = ordena(s1)
s2 = ordena(s2)
if s1 == s2:
	print('YES')
else:
	print('NO')


def cek(x):
	m = len(x)
	if m % 2 == 1:
		return x
	m //= 2
	a = cek(x[:m])
	b = cek(x[m:])
	if a < b:
		return a + b
	else:
		return b + a
a = input()
b = input()
if cek(a) == cek(b):
	print('YES')
else:
	print('NO')


def eqivalent_string(a, b):
	if a == b:
		return True
	if len(a) % 2 != 0:
		return False
	n = len(a)
	a1 = a[0:int(n / 2)]
	a2 = a[int(n / 2):n]
	b1 = b[0:int(n / 2)]
	b2 = b[int(n / 2):n]
	return eqivalent_string(a1, b2) and eqivalent_string(a2, b1) or (eqivalent_string(a1, b1) and eqivalent_string(a2, b2))
a = input()
b = input()
if eqivalent_string(a, b):
	print('YES')
else:
	print('NO')


def igual(cadena1, cadena2, l):
	if cadena1 == cadena2:
		return True
	hl = int(l / 2)
	if l % 2 == 1:
		return cadena1 == cadena2
	else:
		a1 = cadena1[0:hl]
		b1 = cadena2[0:hl]
		a2 = cadena1[hl:l]
		b2 = cadena2[hl:l]
		if igual(a1, b2, hl) and igual(a2, b1, hl):
			return True
		else:
			return igual(a1, b1, hl) and igual(a2, b2, hl)
cadena1 = input()
cadena2 = input()
if igual(cadena1, cadena2, len(cadena1)):
	print('YES')
else:
	print('NO')


import sys

def eql(a, b):
	if a == b:
		return True
	if len(a) % 2 == 1:
		return False
	size = len(a)
	a1 = a[:size // 2]
	a2 = a[size // 2:]
	b1 = b[:size // 2]
	b2 = b[size // 2:]
	return eql(a1, b2) and eql(a2, b1) or (eql(a1, b1) and eql(a2, b2))
str1 = sys.stdin.readline().strip()
str2 = sys.stdin.readline().strip()
if eql(str1, str2):
	print('YES')
else:
	print('NO')


def check(t1, t2):
	l = len(t1)
	if t1 == t2:
		return True
	if l % 2 == 0 and (check(t1[:l // 2], t2[l // 2:]) and check(t2[:l // 2], t1[l // 2:]) or (check(t1[:l // 2], t2[:l // 2]) and check(t2[l // 2:], t1[l // 2:]))):
		return True
	return False
a = str(input())
b = str(input())
if check(a, b):
	print('YES')
else:
	print('NO')


def fu(s):
	if len(s) % 2 == 1:
		return s
	s1 = fu(s[:len(s) // 2])
	s2 = fu(s[len(s) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
a = input()
b = input()
if fu(a) == fu(b):
	print('YES')
else:
	print('NO')


def main():
	a = list(input())
	b = list(input())
	n = len(a)
	k = n
	while k % 2 == 0:
		k = k // 2
	while k != n:
		pairs = n // (k * 2)
		for i in range(0, pairs * 2, 2):
			if a[k * i:k * (i + 1)] > a[k * (i + 1):k * (i + 2)]:
				(a[k * i:k * (i + 1)], a[k * (i + 1):k * (i + 2)]) = (a[k * (i + 1):k * (i + 2)], a[k * i:k * (i + 1)])
			if b[k * i:k * (i + 1)] > b[k * (i + 1):k * (i + 2)]:
				(b[k * i:k * (i + 1)], b[k * (i + 1):k * (i + 2)]) = (b[k * (i + 1):k * (i + 2)], b[k * i:k * (i + 1)])
		k *= 2
	if a == b:
		print('YES')
	else:
		print('NO')
main()


def comparadorDePalavras(palavra1, palavra2):
	if palavra1 == palavra2:
		return True
	if len(palavra1) != len(palavra2):
		return False
	if len(palavra1) % 2 == 1:
		return False
	metade = len(palavra1) // 2
	palavra1_1 = palavra1[:metade]
	palavra2_1 = palavra2[:metade]
	palavra1_2 = palavra1[metade:]
	palavra2_2 = palavra2[metade:]
	return comparadorDePalavras(palavra1_1, palavra2_2) and comparadorDePalavras(palavra1_2, palavra2_1) or (comparadorDePalavras(palavra1_1, palavra2_1) and comparadorDePalavras(palavra1_2, palavra2_2))
palavra1 = input()
palavra2 = input()
if comparadorDePalavras(palavra1, palavra2):
	print('YES')
else:
	print('NO')


input_a = input()
input_b = input()

def isEquivalent(custom_input):
	valid = len(custom_input) & 1 != 0
	if valid:
		return custom_input
	i = isEquivalent(custom_input[0:int(len(custom_input) / 2)])
	j = isEquivalent(custom_input[int(len(custom_input) / 2):len(custom_input)])
	return min(i + j, j + i)
is_input_equivalent = isEquivalent(input_a) == isEquivalent(input_b)
custom_output = 'NO'
if is_input_equivalent == True:
	custom_output = 'YES'
print(custom_output)


def lexmin(s):
	if len(s) & 1:
		return s
	h = len(s) >> 1
	s1 = lexmin(s[:h])
	s2 = lexmin(s[h:])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
a = input()
b = input()
if len(a) & 1:
	if a == b:
		print('YES')
	else:
		print('NO')
elif lexmin(a) == lexmin(b):
	print('YES')
else:
	print('NO')


x = ''
y = ''
dp = {}

def pE(xl, yl, l):
	if x[xl:xl + l] == y[yl:yl + l]:
		return True
	if l & 1:
		return False
	n = l // 2
	if pE(xl, yl + n, n) and pE(xl + n, yl, n):
		return True
	return pE(xl, yl, n) and pE(xl + n, yl + n, n)

def E(x, y):
	return pE(0, 0, len(x))
x = input()
y = input()
if E(x, y):
	print('YES')
else:
	print('NO')


def equa(s):
	if len(s) % 2 != 0:
		return s
	else:
		s1 = equa(s[:len(s) // 2])
		s2 = equa(s[len(s) // 2:])
		if s1 > s2:
			return s2 + s1
		else:
			return s1 + s2
a = input()
b = input()
if equa(a) == equa(b):
	print('YES')
else:
	print('NO')


def compareStr(string):
	lenStr = len(string)
	half = lenStr // 2
	if lenStr % 2 == 0:
		a = compareStr(string[:half])
		b = compareStr(string[half:])
		return min(f'{a}{b}', f'{b}{a}')
	else:
		return string
str1 = input()
str2 = input()
if compareStr(str1) == compareStr(str2):
	print('YES')
else:
	print('NO')


def equivalent(a, b):
	length = len(a)
	if a == b:
		return True
	elif length % 2 == 0 and (equivalent(a[:length // 2], b[length // 2:]) and equivalent(b[:length // 2], a[length // 2:]) or (equivalent(a[:length // 2], b[:length // 2]) and equivalent(b[length // 2:], a[length // 2:]))):
		return True
	else:
		return False
A = input()
B = input()
if equivalent(A, B):
	print('YES')
else:
	print('NO')


s = input()
t = input()

def smallest(st):
	if len(st) % 2:
		return st
	s1 = smallest(st[:len(st) // 2])
	s2 = smallest(st[len(st) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if smallest(s) == smallest(t):
	print('YES')
else:
	print('NO')


import collections
a = input()
b = input()
ca = collections.Counter(a)
cb = collections.Counter(b)

def eq(a, b, ah, at, bh, bt):
	if a[ah:at] == b[bh:bt]:
		return True
	len_a = at - ah
	if len_a % 2 == 1:
		return False
	half = len_a // 2
	am = ah + half
	bm = bh + half
	return eq(a, b, ah, am, bm, bt) and eq(a, b, am, at, bh, bm) or (eq(a, b, ah, am, bh, bm) and eq(a, b, am, at, bm, bt))
if ca != cb:
	print('NO')
elif eq(a, b, 0, len(a), 0, len(b)):
	print('YES')
else:
	print('NO')


M = 1000000007

def gethash(s):
	n = len(s)
	if n % 2 == 1:
		return hash(s) % M
	m = n // 2
	h0 = gethash(s[:m])
	h1 = gethash(s[m:])
	return (h0 + h1) ** 2 % M

def main():
	s1 = input()
	s2 = input()
	if gethash(s1) == gethash(s2):
		print('YES')
	else:
		print('No')
main()


def check(s):
	if len(s) % 2:
		return s
	s1 = check(s[:len(s) // 2])
	s2 = check(s[len(s) // 2:])
	if s1 > s2:
		return s2 + s1
	else:
		return s1 + s2
a = input()
b = input()
if check(a) == check(b):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def equivalent(l1, r1, l2, r2):
	if a[l1:r1] == b[l2:r2]:
		return True
	if (r1 - l1) % 2 == 1:
		return False
	m1 = (l1 + r1) // 2
	m2 = (l2 + r2) // 2
	if equivalent(m1, r1, l2, m2):
		if equivalent(l1, m1, m2, r2):
			return True
		else:
			return False
	elif equivalent(l1, m1, l2, m2):
		if equivalent(m1, r1, m2, r2):
			return True
		else:
			return False
	else:
		return False
if equivalent(0, len(a), 0, len(b)):
	print('YES')
else:
	print('NO')


import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def solve(s):
	if len(s) & 1:
		return s
	(s1, s2) = (solve(s[:len(s) >> 1]), solve(s[len(s) >> 1:]))
	return s1 + s2 if s1 <= s2 else s2 + s1
(s, t) = (input().rstrip(), input().rstrip())
if solve(s) == solve(t):
	print('YES')
else:
	print('NO')


def equ(s1, s2):
	if s1 == s2:
		return True
	if len(s1) & 1:
		return False
	freq1 = []
	freq2 = []
	for i in range(26):
		freq1.append(0)
	for i in range(26):
		freq2.append(0)
	for c in s1:
		freq1[ord(c) - ord('a')] += 1
	for c in s2:
		freq2[ord(c) - ord('a')] += 1
	for i in range(26):
		if freq1[i] != freq2[i]:
			return False
	al = s1[:len(s1) // 2]
	ah = s1[len(s1) // 2:]
	bl = s2[:len(s2) // 2]
	bh = s2[len(s2) // 2:]
	return equ(al, bl) and equ(ah, bh) or (equ(al, bh) and equ(ah, bl))
a = input()
b = input()
if equ(a, b):
	print('YES')
else:
	print('NO')


def lex_sort(a: str) -> str:
	if len(a) % 2:
		return a
	half = len(a) // 2
	left = lex_sort(a[:half])
	right = lex_sort(a[half:])
	if left < right:
		return left + right
	return right + left
a = input()
b = input()
if lex_sort(a) == lex_sort(b):
	print('YES')
else:
	print('NO')


import collections
a = input()
b = input()
ca = collections.Counter(a)
cb = collections.Counter(b)

def eq(a, b):
	if a == b:
		return True
	len_a = len(a)
	if len_a % 2 == 1:
		return False
	half = len_a // 2
	a1 = a[:half]
	a2 = a[half:]
	b1 = b[:half]
	b2 = b[half:]
	return eq(a1, b2) and eq(a2, b1) or (eq(a1, b1) and eq(a2, b2))
if ca != cb:
	print('NO')
elif eq(a, b):
	print('YES')
else:
	print('NO')


str1 = input()
str2 = input()

def compare(s):
	if len(s) % 2 == 1:
		return s
	half = int(len(s) / 2)
	s1 = compare(s[0:half])
	s2 = compare(s[half:len(s)])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if compare(str1) == compare(str2):
	print('YES')
else:
	print('NO')


def idEq(s1, s2):
	l = len(s1)
	if s1 == s2:
		return True
	if l % 2 == 0 and (idEq(s1[:l // 2], s2[l // 2:]) and idEq(s1[l // 2:], s2[:l // 2]) or (idEq(s1[:l // 2], s2[:l // 2]) and idEq(s1[l // 2:], s2[l // 2:]))):
		return True
	return False
s1 = input().rstrip()
s2 = input().rstrip()
if idEq(s1, s2):
	print('YES')
else:
	print('NO')


def check(a, b):
	if a == b:
		return True
	elif len(a) % 2 == 0:
		(aa, ab, ba, bb) = (a[0:len(a) // 2], a[len(a) // 2:len(a)], b[0:len(b) // 2], b[len(b) // 2:len(b)])
		return check(aa, bb) and check(ab, ba) or (check(aa, ba) and check(ab, bb))
	else:
		return False
(abc, bbc) = (input(), input())
if check(abc, bbc):
	print('YES')
else:
	print('NO')


def check(s):
	if len(s) % 2:
		return s
	a = check(s[:len(s) // 2])
	b = check(s[len(s) // 2:])
	return a + b if a < b else b + a
a = str(input())
b = str(input())
if check(a) == check(b):
	print('YES')
else:
	print('NO')


def calculate(string_):
	size_ = len(string_)
	if size_ % 2 == 1:
		return string_
	size_ //= 2
	first_slice = calculate(string_[:size_])
	second_slice = calculate(string_[size_:])
	if second_slice > first_slice:
		return first_slice + second_slice
	else:
		return second_slice + first_slice

def main():
	(string_a, string_b) = (input(), input())
	if calculate(string_a) == calculate(string_b):
		print('YES')
	else:
		print('NO')
main()


def check(a):
	le = len(a)
	if le % 2:
		return a
	l = check(a[:le // 2])
	r = check(a[le // 2:])
	if l < r:
		return l + r
	else:
		return r + l
a = check(input())
b = check(input())
if a == b:
	print('YES')
else:
	print('NO')


s = input()
t = input()

def is_good(x1, y1, x2, y2):
	if s[x1:y1] == t[x2:y2]:
		return True
	elif (y1 - x1) % 2 == 1:
		return False
	elif is_good(x1, (x1 + y1) // 2, (x2 + y2) // 2, y2) and is_good((x1 + y1) // 2, y1, x2, (x2 + y2) // 2):
		return True
	elif is_good(x1, (x1 + y1) // 2, x2, (x2 + y2) // 2) and is_good((x1 + y1) // 2, y1, (x2 + y2) // 2, y2):
		return True
	else:
		return False
if is_good(0, len(s), 0, len(t)):
	print('YES')
else:
	print('NO')


def dividir(corda):
	tamanho = len(corda)
	if tamanho % 2 == 0:
		meio = tamanho // 2
		metade1 = corda[:meio]
		metade2 = corda[meio:]
		c1 = dividir(metade1)
		c2 = dividir(metade2)
		return min(c1 + c2, c2 + c1)
	else:
		return corda
c1 = input()
c2 = input()
if dividir(c1) == dividir(c2):
	print('YES')
else:
	print('NO')


def lexSmaller(s):
	x = len(s)
	if x % 2 == 1:
		return s
	x //= 2
	a = lexSmaller(s[0:x])
	b = lexSmaller(s[x:])
	return a + b if a < b else b + a
(a, b) = (input(), input())
print('YES' if lexSmaller(a) == lexSmaller(b) else 'NO')


memo_dict = {}

def equivalent(a, b):
	if a == b:
		return True
	if (a, b) in memo_dict:
		return memo_dict[a, b]
	strlen = len(a)
	if strlen % 2 != 0:
		return False
	(a1, a2) = (a[:strlen // 2], a[strlen // 2:])
	(b1, b2) = (b[:strlen // 2], b[strlen // 2:])
	res = equivalent(a1, b1) and equivalent(a2, b2) or (equivalent(a1, b2) and equivalent(a2, b1))
	memo_dict[a, b] = res
	memo_dict[b, a] = res
	return res
a = input()
b = input()
if equivalent(a, b):
	print('YES')
else:
	print('NO')


def permut(str):
	if len(str) % 2 != 0:
		return str
	n = len(str)
	s1 = permut(str[:n // 2])
	s2 = permut(str[n // 2:])
	if s1 + s2 > s2 + s1:
		return s1 + s2
	else:
		return s2 + s1
s = input()
t = input()
if permut(s) == permut(t):
	print('YES')
else:
	print('NO')


def f(s):
	if len(s) & 1:
		return s
	a = f(s[:len(s) >> 1])
	b = f(s[len(s) >> 1:])
	return a + b if a < b else b + a
print('YES' if f(input()) == f(input()) else 'NO')


def dc(string):
	if len(string) % 2 != 0:
		return string
	s1 = dc(string[0:len(string) // 2])
	s2 = dc(string[len(string) // 2:len(string)])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
string1 = input()
string2 = input()
if dc(string1) == dc(string2):
	print('YES')
else:
	print('NO')


def sortOnHalf(st):
	if len(st) % 2 == 1:
		return st
	start = sortOnHalf(st[0:int(len(st) / 2)])
	end = sortOnHalf(st[int(len(st) / 2):len(st)])
	if start < end:
		return end + start
	return start + end
s1 = input()
s2 = input()
if sortOnHalf(s1) == sortOnHalf(s2):
	print('YES')
else:
	print('NO')


def solve(s):
	sz = len(s)
	if sz % 2 == 1:
		return s
	a = solve(s[:int(sz / 2)])
	b = solve(s[int(sz / 2):])
	if a < b:
		return a + b
	else:
		return b + a

def main():
	a = input()
	b = input()
	resa = solve(a)
	resb = solve(b)
	if resa == resb:
		print('YES')
	else:
		print('NO')
main()


def sort_string(x):
	size = len(x)
	if size % 2 != 0:
		return x
	mid = size // 2
	x1 = sort_string(x[:mid])
	x2 = sort_string(x[mid:])
	if x1 > x2:
		return x2 + x1
	return x1 + x2
x = input()
y = input()
is_equivalent = sort_string(x) == sort_string(y)
if is_equivalent:
	print('YES')
else:
	print('NO')


def f(s):
	if len(s) % 2 == 1:
		return s
	p = f(s[:len(s) // 2])
	q = f(s[len(s) // 2:])
	if p < q:
		return p + q
	return q + p
s = input()
t = input()
if f(s) == f(t):
	print('YES')
else:
	print('NO')


def equiv(a, b):
	if (a, b) in memo.keys():
		return memo[a, b]
	if len(a) % 2 == 1:
		return a == b
	mid = len(a) // 2
	(a1, a2) = (a[:mid], a[mid:])
	(b1, b2) = (b[:mid], b[mid:])
	memo[a, b] = equiv(a1, b1) and equiv(a2, b2) or (equiv(a1, b2) and equiv(a2, b1))
	return memo[a, b]
a = input()
b = input()
memo = {}
if equiv(a, b):
	print('YES')
else:
	print('NO')


def check(a, b):
	if a == b:
		return True
	length = len(a)
	if length % 2:
		return False
	length //= 2
	return check(a[:length], b[length:]) and check(a[length:], b[:length]) or (check(a[:length], b[:length]) and check(a[length:], b[length:]))
print('YES' if check(input(), input()) else 'NO')


word_a = input()
word_b = input()
n = len(word_a)

def sort_string(word):
	if len(word) % 2 == 1:
		return word
	left = sort_string(word[:len(word) // 2])
	right = sort_string(word[len(word) // 2:len(word)])
	return left + right if left < right else right + left
word_a = sort_string(word_a)
word_b = sort_string(word_b)
print('Yes' if word_a == word_b else 'No')


import sys
input = sys.stdin.readline
a = input().rstrip()
b = input().rstrip()

def small_s(s):
	if len(s) % 2 == 1:
		return s
	s1 = small_s(s[:len(s) // 2])
	s2 = small_s(s[len(s) // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if small_s(a) == small_s(b):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def dfs(sa, sb):
	if sa == sb:
		return True
	if len(sa) & 1:
		return False
	n = len(sa) // 2
	sa1 = sa[:n]
	sa2 = sa[n:]
	sb1 = sb[:n]
	sb2 = sb[n:]
	if dfs(sa1, sb2) and dfs(sa2, sb1):
		return True
	if dfs(sa1, sb1) and dfs(sa2, sb2):
		return True
	return False
if dfs(a, b):
	print('YES')
else:
	print('NO')


from heapq import merge

def f(s):
	l = len(s)
	return [list(merge(f(s[:l >> 1]), f(s[l >> 1:])))] if l & 1 == 0 else [s]
print('YES' if f(input()) == f(input()) else 'NO')


def min_order(s):
	n = len(s)
	if n % 2 != 0:
		return s
	left_s = min_order(s[:n // 2])
	right_s = min_order(s[n // 2:])
	if left_s < right_s:
		return left_s + right_s
	return right_s + left_s
a = input()
b = input()
if min_order(a) == min_order(b):
	print('YES')
else:
	print('NO')


from sys import stdin
map = None

def eq(a, b):
	global map
	if (a, b) in map.keys():
		return map[a, b]
	if a == b:
		map[a, b] = True
		return True
	elif len(a) % 2 != 0:
		map[a, b] = False
		return False
	else:
		map[a, b] = eq(a[0:len(a) // 2], b[0:len(b) // 2]) and eq(a[len(a) // 2:], b[len(b) // 2:]) or (eq(a[len(a) // 2:], b[0:len(b) // 2]) and eq(a[0:len(a) // 2], b[len(b) // 2:]))
		return map[a, b]

def main():
	global map
	a = stdin.readline().strip()
	b = stdin.readline().strip()
	map = {}
	if eq(a, b):
		print('YES')
	else:
		print('No')
main()


def split_(s):
	m = len(s) // 2
	return (s[:m], s[m:])

def eq(a, b):
	if a == b:
		return True
	elif len(a) % 2 == 1 or len(b) % 2 == 1:
		return False
	else:
		(a1, a2) = split_(a)
		(b1, b2) = split_(b)
		if eq(a1, b2) and eq(a2, b1):
			return True
		if eq(a1, b1) and eq(a2, b2):
			return True
	return False
s1 = input()
s2 = input()
if s1 == s2:
	print('YES')
elif len(s1) % 2 == 1:
	print('NO')
else:
	print('YES' if eq(s1, s2) else 'NO')


def equivalent(lhs, rhs):
	if lhs == rhs:
		return True
	if len(lhs) % 2 == 1:
		return lhs == rhs
	length = len(lhs)
	mid = length // 2
	lhs1 = lhs[0:mid]
	lhs2 = lhs[mid:length]
	rhs1 = rhs[0:mid]
	rhs2 = rhs[mid:length]
	if equivalent(lhs1, rhs2) and equivalent(lhs2, rhs1):
		return True
	else:
		return equivalent(lhs1, rhs1) and equivalent(rhs2, lhs2)
s1 = input()
s2 = input()
if equivalent(s1, s2):
	print('YES')
else:
	print('NO')


def isEqual(s):
	l = len(s)
	return sorted([isEqual(s[:l // 2]), isEqual(s[l // 2:])]) if l % 2 == 0 else s
a = input()
b = input()
if isEqual(a) == isEqual(b):
	print('YES')
else:
	print('NO')


def equ(a, b):
	if a == b:
		return True
	la = len(a)
	lb = len(b)
	if la & 1 or lb & 1:
		return False
	if la == 1:
		return False
	as1 = a[0:la // 2]
	as2 = a[la // 2:la]
	bs1 = b[0:lb // 2]
	bs2 = b[lb // 2:lb]
	return equ(as1, bs2) and equ(as2, bs1) or (equ(as1, bs1) and equ(as2, bs2))
s1 = input()
s2 = input()
if equ(s1, s2):
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()

def is_equivalent(a, b):
	if a == b:
		return True
	if len(a) == 1 or len(b) == 1:
		return a == b
	if len(a) % 2 != 0 or len(b) % 2 != 0:
		return False
	mid = len(a) // 2
	(a1, a2) = (a[:mid], a[mid:])
	(b1, b2) = (b[:mid], b[mid:])
	return is_equivalent(a1, b2) and is_equivalent(a2, b1) or (is_equivalent(a1, b1) and is_equivalent(a2, b2))
print('YES' if is_equivalent(s1, s2) else 'NO')


def eqStrings(a, b):
	if a == b:
		return 1
	if len(a) % 2 == 0:
		split = int(len(a) / 2)
	else:
		return 0
	a1 = a[0:split]
	a2 = a[split:len(a)]
	b1 = b[0:split]
	b2 = b[split:len(b)]
	if eqStrings(a1, b2) and eqStrings(a2, b1) == 1:
		return 1
	elif eqStrings(a1, b1) and eqStrings(a2, b2) == 1:
		return 1
	else:
		return 0
a = list(input())
b = list(input())
res = eqStrings(a, b)
if res == 0:
	print('NO')
else:
	print('YES')


s1 = input()
s2 = input()

def Sort(string):
	l = len(string)
	if l % 2 == 1:
		return string
	s1 = Sort(string[:l // 2])
	s2 = Sort(string[l // 2:])
	if s1 < s2:
		return s1 + s2
	else:
		return s2 + s1
if Sort(s1) == Sort(s2):
	print('YES')
else:
	print('NO')


import unittest
import sys

class Strings:

	def __init__(self, args):
		(self.stra, self.strb) = args

	def splitcheck(self, a, b):
		la = len(a)
		lb = len(b)
		if la != lb:
			return 0
		if a == b:
			return 1
		if la % 2 == 1 or lb % 2 == 1:
			return 0
		(a1, a2) = (a[la // 2:], a[:la // 2])
		(b1, b2) = (b[lb // 2:], b[:lb // 2])
		if self.splitcheck(a1, b1) and self.splitcheck(a2, b2):
			return 1
		if self.splitcheck(a1, b2) and self.splitcheck(a2, b1):
			return 1
		return 0

	def calculate(self):
		result = self.splitcheck(self.stra, self.strb)
		return str('YES' if result else 'NO')

def get_inputs(test_inputs=None):
	it = iter(test_inputs.split('\n')) if test_inputs else None

	def uinput():
		if it:
			return next(it)
		else:
			return sys.stdin.readline().rstrip()
	stra = uinput()
	strb = uinput()
	return [stra, strb]

def calculate(test_inputs=None):
	return Strings(get_inputs(test_inputs)).calculate()

class unitTests(unittest.TestCase):

	def test_Strings_class__basic_functions(self):
		d = Strings(['aaaabbbb', 'ababbaba'])
		self.assertEqual(d.stra, 'aaaabbbb')
		self.assertEqual(d.splitcheck('a', 'a'), 1)
		self.assertEqual(d.splitcheck('ab', 'a'), 0)
		self.assertEqual(d.splitcheck('abb', 'aba'), 0)
		self.assertEqual(d.splitcheck('ab', 'ba'), 1)
		self.assertEqual(d.splitcheck('abcdefgh', 'efhgdcba'), 1)

	def test_sample_tests(self):
		test = 'aaba\nabaa'
		self.assertEqual(calculate(test), 'YES')
		self.assertEqual(get_inputs(test)[0], 'aaba')
		self.assertEqual(get_inputs(test)[1], 'abaa')
		test = 'aabb\nabab'
		self.assertEqual(calculate(test), 'NO')
		test = 'abddbbdd\nddbbddba'
		self.assertEqual(calculate(test), 'YES')
		test = 'aabb\nbbaa'
		self.assertEqual(calculate(test), 'YES')

	def test_time_limit_test(self):
		import random
		imax = 100000
		numnums = ['ab' for i in range(imax)]
		test = ''.join(numnums) + '\n'
		numnums = ['aa' for i in range(imax)]
		test += ''.join(numnums) + '\n'
		import timeit
		start = timeit.default_timer()
		args = get_inputs(test)
		init = timeit.default_timer()
		d = Strings(args)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTime Test: ' + '{0:.3f}s (inp {1:.3f}s init {2:.3f}s calc {3:.3f}s)'.format(stop - start, init - start, calc - init, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(calculate())


def equivalentStrings(s1, s2, pairs):
	leng = len(s1)
	if leng % 2 != 0:
		return 'YES' if s1 == s2 else 'NO'
	if s1 == s2:
		pairs.add((s1, s2))
		return 'YES'
	if ((s1, s2) in pairs or (s2, s1) in pairs) or (equivalentStrings(s1[:leng // 2], s2[:leng // 2], pairs) == 'YES' and equivalentStrings(s1[leng // 2:], s2[leng // 2:], pairs) == 'YES') or (equivalentStrings(s1[:leng // 2], s2[leng // 2:], pairs) == 'YES' and equivalentStrings(s1[leng // 2:], s2[:leng // 2], pairs) == 'YES'):
		pairs.add((s1, s2))
		return 'YES'
	return 'NO'
s1 = input()
s2 = input()
pairs = set()
print(equivalentStrings(s1, s2, pairs))


input1 = input()
input2 = input()

def sort(s, length):
	(half, one) = divmod(length, 2)
	if one == 1:
		return s
	else:
		(s1, s2) = (sort(s[:half], half), sort(s[half:], half))
		if s1 < s2:
			return s1 + s2
		else:
			return s2 + s1
if sort(input1, len(input1)) == sort(input2, len(input2)):
	print('YES')
else:
	print('NO')


def lexical_smaller(s):
	if len(s) % 2 == 1:
		return s
	left = lexical_smaller(s[:len(s) // 2])
	right = lexical_smaller(s[len(s) // 2:])
	return left + right if left < right else right + left

def equivalent(s1, s2):
	return lexical_smaller(s1) == lexical_smaller(s2)
a = input()
b = input()
if equivalent(a, b):
	print('YES')
else:
	print('NO')


def sortString(str):
	length = len(str)
	if length % 2 != 0:
		return str
	length //= 2
	left = sortString(str[:length])
	right = sortString(str[length:])
	if left < right:
		return left + right
	else:
		return right + left
a = input()
b = input()
print('YES' if sortString(a) == sortString(b) else 'NO')


def equivalent(a, b):
	n = len(a)
	mid = n // 2
	if n % 2 == 0:
		a1 = a[:mid]
		a2 = a[mid:]
		b1 = b[:mid]
		b2 = b[mid:]
		if a1 == b1 and a2 == b2:
			return True
		elif a1 == b2 and a2 == b1:
			return True
		else:
			return equivalent(a1, b1) and equivalent(a2, b2) or (equivalent(a1, b2) and equivalent(a2, b1))
	else:
		return a == b
a = input()
b = input()
if sorted(list(a)) != sorted(list(b)):
	print('NO')
else:
	print('YES') if equivalent(a, b) else print('NO')


a = input()
b = input()
mas = {}

def rasch(a, b):
	nonlocal mas
	s = a + b
	if a == b:
		mas[s] = 2
		return True
	else:
		if mas.get(s):
			return True if mas[s] == 2 else False
		if len(a) % 2 == 0:
			a1 = a[0:len(a) // 2]
			a2 = a[len(a) // 2:]
			b1 = b[0:len(a) // 2]
			b2 = b[len(a) // 2:]
			res = rasch(a1, b1) and rasch(a2, b2) or (rasch(a1, b2) and rasch(a2, b1))
			mas[s] = 2 if res else 1
			return res
		else:
			return False
print('YES') if rasch(a, b) else print('NO')


a = input()
b = input()

def dividir_para_conquistar(c):
	s_size = len(c)
	if s_size % 2:
		return c
	s1 = dividir_para_conquistar(c[0:int(s_size / 2)])
	s2 = dividir_para_conquistar(c[int(s_size / 2):s_size])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
a = dividir_para_conquistar(a)
b = dividir_para_conquistar(b)
if a == b:
	print('YES')
else:
	print('NO')


def divide_letras(palavra):
	tamanho = len(palavra)
	if tamanho % 2 == 1:
		return palavra
	tamanho = tamanho // 2
	esquerda = divide_letras(palavra[:tamanho])
	direita = divide_letras(palavra[tamanho:])
	if esquerda < direita:
		return esquerda + direita
	else:
		return direita + esquerda
a = input()
b = input()
if divide_letras(a) == divide_letras(b):
	print('YES ')
else:
	print('NO')


def reorder(a):
	length = len(a)
	if length % 2 == 1:
		return a
	else:
		return sorted([reorder(a[:length // 2]), reorder(a[length // 2:])])
if reorder(input()) == reorder(input()):
	print('YES')
else:
	print('NO')


def read_list(t):
	return [t(x) for x in input().split()]

def read_line(t):
	return t(input())

def read_lines(t, N):
	return [t(input()) for _ in range(N)]

def smallest(s):
	len_s = len(s)
	if len_s & 1:
		return s
	s1 = smallest(s[:len_s // 2])
	s2 = smallest(s[len_s // 2:])
	return s1 + s2 if s1 < s2 else s2 + s1
S1 = read_line(str)
S2 = read_line(str)
print('YES' if smallest(S1) == smallest(S2) else 'NO')


def isEquivalent(at, bt):
	if at == bt:
		return True
	size = len(at)
	if size % 2 == 1:
		return False
	mid = size // 2
	a1 = at[:mid]
	a2 = at[mid:]
	b1 = bt[:mid]
	b2 = bt[mid:]
	return isEquivalent(a1, b2) and isEquivalent(a2, b1) or (isEquivalent(a1, b1) and isEquivalent(a2, b2))
a = input()
b = input()
if isEquivalent(a, b):
	print('YES')
else:
	print('NO')


def mergeSort(string):
	if len(string) % 2 == 1:
		return string
	else:
		middle = round(len(string) / 2)
		stringA = mergeSort(string[0:middle])
		stringB = mergeSort(string[middle:])
		if stringA < stringB:
			return stringA + stringB
		else:
			return stringB + stringA
stringA = input()
stringB = input()
if mergeSort(stringA) == mergeSort(stringB):
	print('YES')
else:
	print('NO')


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)

def equilibrium(current):
	length = len(current)
	if length % 2 == 1:
		return current
	new1 = equilibrium(current[:length // 2])
	new2 = equilibrium(current[length // 2:])
	if new1 < new2:
		return new1 + new2
	else:
		return new2 + new1
string1 = equilibrium(f_input().replace('\n', ''))
string2 = equilibrium(f_input().replace('\n', ''))
f_print('YES' if string1 == string2 else 'NO')


def equiv(s):
	if len(s) % 2 == 1:
		return s
	a = equiv(s[:len(s) // 2])
	b = equiv(s[len(s) // 2:])
	return a + b if a < b else b + a
(a, b) = (input(), input())
print(('NO', 'YES')[equiv(a) == equiv(b)])


a = input()
b = input()

def equivalent_strings(string):
	len_string = len(string)
	if len_string % 2 == 0:
		n = int(len_string / 2)
		(string_1, string_2) = (equivalent_strings(string[:n]), equivalent_strings(string[n:]))
		return sorted([string_1, string_2])
	else:
		return string
if equivalent_strings(a) == equivalent_strings(b):
	print('YES')
else:
	print('NO')


def sortString(s):
	if len(s) % 2 != 0:
		return s
	else:
		(s1, s2) = [sortString(s[:len(s) // 2]), sortString(s[len(s) // 2:])]
		return sorted([s1, s2])
a = input()
b = input()
if sortString(a) == sortString(b):
	print('YES')
else:
	print('NO')


def slice_halves(string, length):
	half = length // 2
	return (string[:half], string[half:])

def sort_substrings(string):
	length = len(string)
	if length % 2 == 0:
		(left_half, right_half) = slice_halves(string, length)
		(a, b) = (sort_substrings(left_half), sort_substrings(right_half))
		return min(f'{a}{b}', f'{b}{a}')
	else:
		return string

def is_equivalent(a, b):
	return sort_substrings(a) == sort_substrings(b)
(a, b) = (input(), input())
print('YES' if is_equivalent(a, b) else 'NO')


from sys import setrecursionlimit
setrecursionlimit(10 ** 5)

def _print(res):
	print('YES') if res else print('NO')

def split(a):
	(r, q) = (a[0:int(len(a) / 2)], a[int(len(a) / 2):len(a)])
	return (r, q)

def check(string):
	if len(string) % 2 == 0:
		(substring1, substring2) = split(string)
		substring1 = check(substring1)
		substring2 = check(substring2)
		return substring1 + substring2 if substring1 < substring2 else substring2 + substring1
	else:
		return string

def equivalence(a, b):
	if check(a) == check(b):
		print('YES')
	else:
		print('NO')
a = input()
b = input()
equivalence(a, b)


from functools import lru_cache
a = input()
b = input()

@lru_cache(maxsize=1 << 12)
def check_equ(a, b):
	if a == b:
		return True
	if len(a) % 2 > 0 or len(b) % 2 > 0 or len(a) != len(b):
		return False
	(a1, a2) = (a[:len(a) // 2], a[len(a) // 2:])
	(b1, b2) = (b[:len(a) // 2], b[len(a) // 2:])
	return check_equ(a1, b1) and check_equ(a2, b2) or (check_equ(a1, b2) and check_equ(a2, b1))
print('YES' if check_equ(a, b) else 'NO')


s1 = input()
s2 = input()

def check(s1, s2):
	if s1 == s2:
		return 1
	if len(s1) == 1 or (len(s1) % 2 != 0 and s1 != s2):
		return 0
	return check(s1[len(s1) // 2:], s2[0:len(s2) // 2]) and check(s1[:len(s1) // 2], s2[len(s2) // 2:]) or (check(s1[len(s1) // 2:], s2[len(s2) // 2:]) and check(s1[:len(s1) // 2], s2[:len(s2) // 2]))
if check(s1, s2):
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
import math
from math import gcd
import bisect

def equivalente(a, b):
	if a == b:
		return True
	m = len(a)
	if m % 2 == 1:
		return False
	n = int(m / 2)
	a1 = a[0:n]
	a2 = a[n:m]
	b1 = b[0:n]
	b2 = b[n:m]
	return equivalente(a1, b2) and equivalente(a2, b1) or (equivalente(a1, b1) and equivalente(a2, b2))
a = input()
b = input()
if equivalente(a, b):
	print('YES')
else:
	print('NO')


a = input()
b = input()
mapa = {}

def equals(a, b):
	if a == b:
		return 1
	if len(a) % 2 != 0:
		return 0
	if (a, b) in mapa.keys():
		return mapa[a, b]
	tamA = int(len(a) / 2)
	tamB = int(len(b) / 2)
	a1 = a[:tamA]
	a2 = a[tamA:]
	b1 = b[:tamB]
	b2 = b[tamB:]
	if equals(a1, b1) and equals(a2, b2) or (equals(a1, b2) and equals(a2, b1)):
		mapa[a, b] = 1
		return 1
	mapa[a, b] = 0
	return 0
if equals(a, b):
	print('YES')
else:
	print('NO')


def g(s):
	l = len(s)
	return s if l % 2 == 1 else sorted([g(s[:l // 2]), g(s[l // 2:])])
print('YES' if g(input()) == g(input()) else 'NO')


x = input()
y = input()

def f(x, y):
	if x == y:
		return True
	if len(x) % 2 == 1:
		return False
	mid = len(x) // 2
	if f(x[:mid], y[mid:]) and f(x[mid:], y[:mid]):
		return True
	if f(x[mid:], y[mid:]) and f(x[:mid], y[:mid]):
		return True
	return False
if f(x, y):
	print('YES')
	quit()
print('NO')


import unittest

def solve(a, b):

	def msort(s):
		l = len(s)
		if l % 2:
			return s
		mid_idx = l // 2
		s1 = msort(s[:mid_idx])
		s2 = msort(s[mid_idx:])
		return s1 + s2 if s1 < s2 else s2 + s1
	return msort(a) == msort(b)

def getinput():

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

def test():
	art = Assert()
	art.equal(solve('aaba', 'abaa'), True)
	art.equal(solve('aabb', 'abab'), False)

def main():
	print('YES' if solve(*getinput()) else 'NO')

class Assert(unittest.TestCase):

	def equal(self, a, b):
		self.assertEqual(a, b)
main()


def f(l, r, a):
	if (r - l) % 2 == 0:
		return a[l:r + 1]
	else:
		s1 = f(l, int((l + r) / 2), a)
		s2 = f(int((l + r) / 2) + 1, r, a)
		return min(s1, s2) + max(s1, s2)
a = input()
b = input()
n = len(a)
if f(0, n - 1, a) == f(0, n - 1, b):
	print('YES')
else:
	print('NO')


def transform(s):
	l = len(s)
	if l % 2:
		return s
	return sorted([transform(s[:l // 2]), transform(s[l // 2:])])
print(('NO', 'YES')[transform(input()) == transform(input())])


def main():

	def f(lo, hi):
		if not hi - lo & 1:
			mi = (hi + lo) // 2
			f(lo, mi)
			f(mi, hi)
			(s1, s2) = (a[lo:mi], a[mi:hi])
			if s1 < s2:
				(a[lo:mi], a[mi:hi]) = (s2, s1)
			(s1, s2) = (b[lo:mi], b[mi:hi])
			if s1 < s2:
				(b[lo:mi], b[mi:hi]) = (s2, s1)
	(a, b) = (list(input()), list(input()))
	f(0, len(a))
	print(('NO', 'YES')[a == b])
main()


def stringPass(palavra):
	if len(palavra) % 2 != 0:
		return palavra
	corte1 = slice(0, int(len(palavra) / 2), 1)
	corte2 = slice(int(len(palavra) / 2), len(palavra), 1)
	p1 = stringPass(palavra[corte1])
	p2 = stringPass(palavra[corte2])
	if p1 < p2:
		return p1 + p2
	else:
		return p2 + p1
a = input()
b = input()
if stringPass(a) == stringPass(b):
	print('YES')
else:
	print('NO')


def getmin(s):
	l = len(s)
	if l % 2 == 1:
		return s
	else:
		a = getmin(s[0:l // 2])
		b = getmin(s[l // 2:l])
		if a < b:
			return a + b
		else:
			return b + a
s1 = input()
s2 = input()
a1 = getmin(s1)
a2 = getmin(s2)
if a2 == a1:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()

def get_halfs(s: str):
	return (s[:len(s) // 2], s[len(s) // 2:])

def cmp_strs(s1: str, s2: str):
	if s1 == s2:
		return True
	elif len(s1) % 2 == 1:
		return False
	else:
		(a1, a2) = get_halfs(s1)
		(b1, b2) = get_halfs(s2)
		return cmp_strs(a1, b2) and cmp_strs(b1, a2) or (cmp_strs(a1, b1) and cmp_strs(a2, b2))
val = cmp_strs(s1, s2)
print('YES' if val else 'NO')


def encode(s):
	n = len(s)
	if n % 2 == 0:
		l = encode(s[:n // 2])
		r = encode(s[n // 2:])
		return l + r if l < r else r + l
	return s
s = input()
t = input()
print('YES' if encode(s) == encode(t) else 'NO')


def f(s):
	if len(s) % 2 != 0:
		return s
	return sorted([f(s[:len(s) // 2]), f(s[len(s) // 2:])])
if f(input()) == f(input()):
	print('YES')
else:
	print('NO')


def equivalent(string):
	if len(string) % 2 == 1:
		return string
	str1 = equivalent(string[:len(string) // 2])
	str2 = equivalent(string[len(string) // 2:])
	if str1 < str2:
		return str1 + str2
	else:
		return str2 + str1
a = input()
b = input()
if equivalent(a) == equivalent(b):
	print('YES')
else:
	print('NO')


def lhalf(txt):
	return txt[0:len(txt) // 2]

def rhalf(txt):
	return txt[len(txt) // 2:]

def rsort(txt):
	if len(txt) % 2 == 1:
		return txt
	else:
		subtxt1 = rsort(lhalf(txt))
		subtxt2 = rsort(rhalf(txt))
		return ''.join(sorted([subtxt1, subtxt2]))
txt1 = input()
txt2 = input()
if rsort(txt1) == rsort(txt2):
	print('YES')
else:
	print('NO')


def rec(s1):
	if len(s1) % 2:
		return s1
	a = rec(s1[:len(s1) // 2])
	b = rec(s1[len(s1) // 2:])
	if a < b:
		return a + b
	else:
		return b + a
s1 = input()
s2 = input()
if rec(s1) == rec(s2):
	print('YES')
else:
	print('NO')


def divide(string):
	if len(string) % 2 == 1:
		return string
	string1 = divide(string[:len(string) // 2])
	string2 = divide(string[len(string) // 2:])
	if string1 < string2:
		return string1 + string2
	else:
		return string2 + string1
a = divide(input())
b = divide(input())
if a == b:
	print('YES')
else:
	print('NO')


def divide(givenString):
	lengthOfStr = len(givenString)
	if lengthOfStr % 2 == 0:
		firstHalf = divide(givenString[:lengthOfStr // 2])
		secondHalf = divide(givenString[lengthOfStr // 2:])
		combA = f'{firstHalf}{secondHalf}'
		combB = f'{secondHalf}{firstHalf}'
		if combA < combB:
			return combA
		else:
			return combB
	else:
		return givenString
a = input()
b = input()
if divide(a) == divide(b):
	print('YES')
else:
	print('NO')


def merge(s):
	if len(s) % 2 == 1:
		return s
	else:
		left = merge(s[:len(s) // 2])
		right = merge(s[len(s) // 2:])
		if left < right:
			return left + right
		else:
			return right + left
a = input()
b = input()
a = merge(a)
b = merge(b)
c = a == b
if c:
	print('YES')
else:
	print('NO')


def eq(s1, s2):
	if s1 == s2:
		return True
	elif len(s1) != len(s2) or len(s1) % 2 == 1:
		return False
	else:
		k = int(len(s1) / 2)
		return eq(s1[:k], s2[:k]) and eq(s1[k:], s2[k:]) or (eq(s1[k:], s2[:k]) and eq(s2[k:], s1[:k]))
if eq(input(), input()):
	print('YES')
else:
	print('NO')


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
mod = 1000000007
res = ['NO', 'YES']

def solve(a):
	l = len(a)
	if l % 2:
		return a
	l //= 2
	x = solve(a[:l])
	y = solve(a[l:])
	return x + y if x < y else y + x
test = 1
test_case = 1
while test <= test_case:
	test += 1
	print(res[solve(input()) == solve(input())])


first = input()
second = input()

def equals(first, second):
	if first == second:
		return True
	elif len(first) == 1:
		return False
	elif len(first) % 2 == 1:
		return False
	d = len(first) // 2
	return equals(first[:d], second[d:]) and equals(first[d:], second[:d]) or (equals(first[:d], second[:d]) and equals(first[d:], second[d:]))
print('YES' if equals(first, second) else 'NO')


def sort(string):
	length = len(string)
	if length % 2 == 0:
		firstPartOfArray = sort(string[0:int(length / 2)])
		secondPartOfArray = sort(string[int(length / 2):length])
		if firstPartOfArray < secondPartOfArray:
			return firstPartOfArray + secondPartOfArray
		else:
			return secondPartOfArray + firstPartOfArray
	else:
		return string

def equivalentStrings(firstString, secondString):
	if sort(firstString) == sort(secondString):
		return 'YES'
	else:
		return 'NO'
print(equivalentStrings(input(), input()))


import math
a = input()
b = input()

def equivalent(a, b):
	if a == b:
		return True
	elif len(a) % 2 != 0:
		return False
	else:
		x = len(a)
		x = x // 2
		a1 = a[:x]
		a2 = a[x:]
		b1 = b[:x]
		b2 = b[x:]
		return equivalent(a1, b1) and equivalent(a2, b2) or (equivalent(a2, b1) and equivalent(a1, b2))
if equivalent(a, b):
	print('YES')
else:
	print('NO')


def isEquivalent(a, b):
	if a == b:
		return True
	if len(a) == 1 or len(b) == 1:
		return False
	if len(a) % 2 != 0 or len(b) % 2 != 0:
		return False
	threshold = len(a) // 2
	a_half_1 = a[:threshold]
	a_half_2 = a[threshold:]
	b_half_1 = b[:threshold]
	b_half_2 = b[threshold:]
	return isEquivalent(a_half_1, b_half_2) and isEquivalent(a_half_2, b_half_1) or (isEquivalent(a_half_1, b_half_1) and isEquivalent(a_half_2, b[threshold:]))
str1 = input()
str2 = input()
if isEquivalent(str1, str2):
	print('YES')
else:
	print('NO')


import itertools
import sys

def binSearch(str):
	if len(str) % 2 != 0:
		return str
	nr = len(str) // 2
	left = binSearch(str[:nr])
	right = binSearch(str[nr:])
	if left < right:
		return left + right
	else:
		return right + left
s1 = input()
s2 = input()
if binSearch(s1) == binSearch(s2):
	print('YES')
else:
	print('NO')


def si(a, b):
	if a == b:
		return True
	longitud = max(len(a), len(b))
	if longitud % 2 == 1:
		if a == b:
			return True
		else:
			return False
	media = longitud // 2
	if si(a[0:media], b[0:media]) and si(a[media:], b[media:]):
		return True
	if si(a[media:], b[0:media]) and si(a[0:media], b[media:]):
		return True
	return False
primero = input()
segundo = input()
if si(primero, segundo):
	print('YES')
else:
	print('NO')


from collections import Counter
s = input().strip()
t = input().strip()

def solution(a, b):

	def simulate(s, t, l):
		if s == t:
			return True
		if l % 2 == 0:
			l //= 2
			return simulate(s[:l], t[:l], l) and simulate(s[l:], t[l:], l) or (simulate(s[:l], t[l:], l) and simulate(s[l:], t[:l], l))
		return False
	l = len(s)
	if Counter(a) != Counter(b):
		return False
	return simulate(a, b, l)
print('YES' if solution(s, t) else 'NO')


def cut(a, b):
	l = len(a)
	if a == b:
		return True
	elif l % 2 == 0:
		y = 0
		middle = l // 2
		return cut(a[0:middle], b[middle:l + 1]) and cut(a[middle:l + 1], b[0:middle]) or (cut(a[0:middle], b[0:middle]) and cut(a[middle:l + 1], b[middle:l + 1]))
	else:
		return False
if cut(input(), input()):
	print('YES')
else:
	print('NO')


def isEqual(a, b):
	for i in range(0, len(a)):
		if a[i] != b[i]:
			return False
	return True

def lexicographic_minimal_string(s):
	if len(s) % 2 == 1:
		return s
	half = int(len(s) / 2)
	s1 = lexicographic_minimal_string(s[:half])
	s2 = lexicographic_minimal_string(s[half:])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
a = input()
b = input()
a = lexicographic_minimal_string(a)
b = lexicographic_minimal_string(b)
if isEqual(a, b):
	print('YES')
else:
	print('NO')


def Equiv(s):
	if len(s) % 2 != 0:
		return s
	half = len(s) // 2
	first = Equiv(s[:half])
	second = Equiv(s[half:])
	if first > second:
		return second + first
	else:
		return first + second

def main():
	a = input().strip()
	b = input().strip()
	if len(a) != len(b):
		print('NO')
		return 0
	if a == b:
		print('YES')
		return 0
	c = Equiv(a)
	d = Equiv(b)
	if c == d:
		print('YES')
	else:
		print('NO')
main()


def split(x):
	end = len(x)
	if end % 2 == 0:
		stra = split(x[0:int(end / 2)])
		strb = split(x[int(end / 2):])
		if stra > strb:
			return [strb, stra]
		else:
			return [stra, strb]
	else:
		return x
a = str(input())
b = str(input())
if split(a) == split(b):
	print('YES')
else:
	print('NO')


def equivalence(s1, s2):
	if s1 == s2:
		return True
	if len(s1) % 2 == 1:
		return False
	a1 = s1[:len(s1) // 2]
	a2 = s1[len(s1) // 2:]
	b1 = s2[:len(s2) // 2]
	b2 = s2[len(s2) // 2:]
	return equivalence(a1, b2) and equivalence(a2, b1) or (equivalence(a1, b1) and equivalence(a2, b2))
s1 = input()
s2 = input()
ans = equivalence(s1, s2)
if ans == True:
	print('YES')
else:
	print('NO')


def eq(s1, s2):
	if s1 == s2:
		return 1
	elif len(s1) == 1 or (len(s1) % 2 != 0 and s1 != s2):
		return 0
	mid = len(s1) // 2
	return eq(s1[:mid], s2[mid:]) and eq(s1[mid:], s2[:mid]) or (eq(s1[:mid], s2[:mid]) and eq(s1[mid:], s2[mid:]))
(s1, s2) = (input(), input())
print('YES' if eq(s1, s2) == 1 else 'NO')


import math
import collections
import bisect
import heapq
import time
import random
a = input()
b = input()

def smallest(s):
	n = len(s)
	if n % 2 == 1:
		return s
	s1 = smallest(s[:n // 2])
	s2 = smallest(s[n // 2:])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
a = smallest(a)
b = smallest(b)
if a == b:
	print('YES')
else:
	print('NO')


a = input()
b = input()

def is_equal(x, y):
	if x == y:
		return True
	if len(x) % 2 == 0 and len(y) % 2 == 0:
		l = int(len(x) / 2)
		return is_equal(x[:l], y[l:]) and is_equal(x[l:], y[:l]) or (is_equal(x[:l], y[:l]) and is_equal(x[l:], y[l:]))
	return False
print('YES' if is_equal(a, b) else 'NO')


def slice_halves(string, length):
	half = length // 2
	return (string[:half], string[half:])

def sort_substrings(string):
	length = len(string)
	if length % 2 == 0:
		(half_1, half_2) = slice_halves(string, length)
		(a, b) = (sort_substrings(half_1), sort_substrings(half_2))
		return min(f'{a}{b}', f'{b}{a}')
	else:
		return string

def is_equivalent(a, b):
	return sort_substrings(a) == sort_substrings(b)
(a, b) = (input(), input())
print('YES' if is_equivalent(a, b) else 'NO')


def equal(a, b):

	def msort(s):
		length = len(s)
		if length % 2:
			return s
		s1 = msort(s[:length // 2])
		s2 = msort(s[length // 2:])
		if s1 < s2:
			return s1 + s2
		else:
			return s2 + s1
	if msort(a) == msort(b):
		return True
	else:
		return False
a = input()
b = input()
print('YES' if equal(a, b) else 'NO')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999
alphabets = 'abcdefghijklmnopqrstuvwxyz'

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class SegTree:

	def __init__(self, n):
		self.N = 1 << n.bit_length()
		self.tree = [0] * (self.N << 1)

	def update(self, i, j, v):
		i += self.N
		j += self.N
		while i <= j:
			if i % 2 == 1:
				self.tree[i] += v
			if j % 2 == 0:
				self.tree[j] += v
			(i, j) = (i + 1 >> 1, j - 1 >> 1)

	def query(self, i):
		v = 0
		i += self.N
		while i > 0:
			v += self.tree[i]
			i >>= 1
		return v

def SieveOfEratosthenes(limit):
	isPrime = [True] * (limit + 1)
	isPrime[0] = isPrime[1] = False
	primes = []
	for i in range(2, limit + 1):
		if not isPrime[i]:
			continue
		primes += [i]
		for j in range(i * i, limit + 1, i):
			isPrime[j] = False
	return primes

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		a = list(rs())
		b = list(rs())

		def check_equivalency(a, b):
			if a == b:
				return True
			if len(a) % 2:
				return False
			(a1, a2) = (a[:len(a) // 2], a[len(a) // 2:])
			(b1, b2) = (b[:len(b) // 2], b[len(b) // 2:])
			if check_equivalency(a1, b2) and check_equivalency(a2, b1) or (check_equivalency(a1, b1) and check_equivalency(a2, b2)):
				return True
			return False
		if check_equivalency(a, b):
			ws('YES')
		else:
			ws('NO')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]

def F(s):
	if len(s) % 2 == 1:
		return s
	s1 = F(s[:len(s) // 2])
	s2 = F(s[len(s) // 2:])
	if s1 < s2:
		return s1 + s2
	return s2 + s1
F1 = F(input())
F2 = F(input())
print(['NO', 'YES'][F1 == F2])


def comparassion(palavra_1, palavra_2):
	if palavra_1 == palavra_2:
		return True
	if len(palavra_1) % 2 != 0 or len(palavra_2) % 2 != 0:
		return False
	center = len(palavra_1) // 2
	left_1 = palavra_1[:center]
	right_1 = palavra_1[center:]
	left_2 = palavra_2[:center]
	right_2 = palavra_2[center:]
	return comparassion(left_1, right_2) and comparassion(right_1, left_2) or (comparassion(left_1, left_2) and comparassion(right_1, right_2))
palavra_1 = input()
palavra_2 = input()
if comparassion(palavra_1, palavra_2):
	print('YES')
else:
	print('NO')


memo = {}

def recur(sa, sb):
	if sa + sb in memo:
		return memo[sa + sb]
	if len(sa) == 0 or len(sb) == 0:
		return False
	if len(sa) % 2 == 1 or len(sb) % 2 == 1:
		return sa == sb
	if len(sa) == len(sb) and len(sa) == 2:
		sa = ''.join(sorted(sa))
		sb = ''.join(sorted(sb))
		if sa == sb:
			memo[sa + sb] = True
			return True
		else:
			memo[sa + sb] = False
			return False
	la = len(sa) // 2
	lb = len(sb) // 2
	if recur(sa[:la], sb[:lb]) and recur(sa[la:], sb[lb:]) or (recur(sa[:la], sb[lb:]) and recur(sa[la:], sb[:lb])):
		memo[sa + sb] = True
		return True
	else:
		memo[sa + sb] = False
		return False
sa = input()
sb = input()
if recur(sa, sb):
	print('YES')
else:
	print('NO')


def verificar_compatibilidade(string1, string2):
	if string1 == string2:
		return True
	elif len(string1) % 2 == 1:
		return False
	else:
		k = len(string1) // 2
		resp1 = verificar_compatibilidade(string1[0:k], string2[k:len(string1)])
		if resp1:
			resp2 = verificar_compatibilidade(string2[0:k], string1[k:len(string1)])
			if resp2:
				return True
		resp3 = verificar_compatibilidade(string1[0:k], string2[0:k])
		if resp3:
			resp4 = verificar_compatibilidade(string1[k:len(string1)], string2[k:len(string1)])
			if resp4:
				return True
	return False

def main():
	string1 = input()
	string2 = input()
	resposta = verificar_compatibilidade(string1, string2)
	if resposta:
		print('YES')
	else:
		print('NO')
main()


import sys
import copy
from math import *
from collections import deque
sys.setrecursionlimit(10 ** 7)

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output2.txt', 'w')
a = list(input().rstrip())
b = list(input().rstrip())
c = 0

def rec(a):
	global c
	if len(a) & 1 == 1:
		return a
	s1 = rec(a[len(a) // 2:])
	s2 = rec(a[:len(a) // 2])
	return min(s1, s2) + max(s1, s2)
print('YES' if rec(a) == rec(b) else 'NO')


def solve(a):
	if len(a) & 1:
		return a
	first = solve(a[0:len(a) // 2])
	second = solve(a[len(a) // 2:len(a)])
	if first < second:
		return first + second
	else:
		return second + first
a = input()
b = input()
if solve(a) == solve(b):
	print('YES')
else:
	print('NO')


def isEq(a, b, la, lb):
	if la + lb == 2 or la % 2 == 1 or lb % 2 == 1:
		if a == b:
			return True
		else:
			return False
	else:
		a1 = a[:la // 2]
		a2 = a[la // 2:]
		b1 = b[:lb // 2]
		b2 = b[lb // 2:]
		res1 = isEq(a1, b1, la // 2, lb // 2)
		res2 = isEq(a2, b2, la - la // 2, lb - lb // 2)
		if res1 and res2:
			return True
		else:
			return False

def merge(s):
	if len(s) % 2 == 1:
		return s
	else:
		left = merge(s[:len(s) // 2])
		right = merge(s[len(s) // 2:])
		if left < right:
			return left + right
		else:
			return right + left
a = input()
b = input()
a = merge(a)
b = merge(b)
c = isEq(a, b, len(a), len(b))
if c:
	print('YES')
else:
	print('NO')


def solution(s1, s2):
	if s1 == s2:
		return True
	if len(s1) % 2 == 1:
		return False
	mid = int(len(s1) / 2)
	left = solution(s1[:mid], s2[:mid])
	if left:
		right = solution(s1[mid:], s2[mid:])
		return right
	cross_left = solution(s1[mid:], s2[:mid])
	if cross_left:
		cross_right = solution(s1[:mid], s2[mid:])
		return cross_right
	return False
s1 = input()
s2 = input()
if solution(s1, s2):
	print('YES')
else:
	print('NO')


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def remake(s):
	if len(s) & 1:
		return s
	n = len(s) // 2
	s1 = s[:n]
	s2 = s[n:]
	s1 = remake(s1)
	s2 = remake(s2)
	return min(s1, s2) + max(s1, s2)

def solve():
	a = si()
	b = si()
	if remake(a) == remake(b):
		print('YES')
	else:
		print('NO')
solve()


def eq(st1, st2):
	if st1 == st2:
		return 1
	if len(st1) % 2 == 1:
		return 0
	if eq(st1[:len(st1) // 2], st2[len(st1) // 2:]) and eq(st2[:len(st1) // 2], st1[len(st1) // 2:]):
		return 1
	if eq(st1[:len(st1) // 2], st2[:len(st1) // 2]) and eq(st1[len(st1) // 2:], st2[len(st1) // 2:]):
		return 1
	return 0
s1 = [i for i in input()]
s2 = [i for i in input()]
if eq(s1, s2):
	print('YES')
else:
	print('NO')


(A, B) = ('', '')

def process(string):
	if len(string) % 2 != 1:
		m = int(len(string) / 2)
		l = process(string[:m])
		r = process(string[m:])
		if l < r:
			return l + r
		return r + l
	return string

def entrypoint():
	global A, B
	A = input()
	B = input()

def main():
	entrypoint()
	retA = process(A)
	retB = process(B)
	if retA == retB:
		print('YES')
	else:
		print('NO')
main()


def iseqi(s1, s2):
	if s1 + s2 in string_dict:
		return string_dict[s1 + s2]
	if len(s1) % 2 == 1:
		if s1 == s2:
			return True
			string_dict[s1 + s2] = True
		else:
			string_dict[s1 + s2] = False
			return False
	else:
		l = len(s1) // 2
		if iseqi(s1[:l], s2[:l]) and iseqi(s1[l:], s2[l:]) or (iseqi(s1[:l], s2[l:]) and iseqi(s1[l:], s2[:l])):
			string_dict[s1 + s2] = True
			return True
		else:
			string_dict[s1 + s2] = False
			return False
s1 = input()
s2 = input()
if len(s1) != len(s2):
	print('NO')
	quit()
string_dict = dict()
if iseqi(s1, s2):
	print('YES')
else:
	print('NO')


palabras = {}

def equivalente(ca1, ca2):
	if (ca1, ca2) in palabras:
		return palabras[ca1, ca2]
	if ca1 == ca2:
		return True
	if len(ca1) % 2 == 1 or len(ca2) % 2 == 1:
		return False
	a1 = ca1[:len(ca1) // 2]
	a2 = ca1[len(ca1) // 2:]
	b1 = ca2[:len(ca2) // 2]
	b2 = ca2[len(ca2) // 2:]
	palabras[ca1, ca2] = equivalente(a1, b1) and equivalente(a2, b2) or (equivalente(a1, b2) and equivalente(a2, b1))
	return palabras[ca1, ca2]
a = input()
b = input()
if equivalente(a, b):
	print('YES')
else:
	print('NO')


def solve(a, b):
	if a == b:
		return True
	if len(a) == 1 or len(b) == 1:
		return False
	if len(a) != len(b) or len(a) % 2 != 0:
		return False
	half_size = len(a) // 2
	a1 = a[:half_size]
	a2 = a[half_size:]
	b1 = b[:half_size]
	b2 = b[half_size:]
	return solve(a1, b2) and solve(a2, b1) or (solve(a1, b1) and solve(a2, b2))
wa = input()
wb = input()
if solve(wa, wb):
	print('YES')
else:
	print('NO')


def reorder(string):
	half = int(len(string) / 2)
	if len(string) % 2 == 1:
		return string
	first_half = reorder(string[:half])
	second_half = reorder(string[half:])
	if first_half < second_half:
		return first_half + second_half
	else:
		return second_half + first_half
a = reorder(input())
b = reorder(input())
if a == b:
	print('YES')
else:
	print('NO')


def equivalent(string):
	end = len(string)
	if end % 2 == 0:
		stra = equivalent(string[0:int(end / 2)])
		strb = equivalent(string[int(end / 2):])
		if stra > strb:
			return [strb, stra]
		else:
			return [stra, strb]
	else:
		return string
a = str(input())
b = str(input())
if equivalent(a) == equivalent(b):
	print('YES')
else:
	print('NO')


def equal(s1, s2, size):
	if s1 == s2:
		return True
	half = int(size / 2)
	if size % 2 == 1:
		return s1 == s2
	else:
		a1 = s1[0:half]
		b1 = s2[0:half]
		a2 = s1[half:size]
		b2 = s2[half:size]
		if equal(a1, b2, half) and equal(a2, b1, half):
			return True
		else:
			return equal(a1, b1, half) and equal(a2, b2, half)
s1 = input()
s2 = input()
if equal(s1, s2, len(s1)):
	print('YES')
else:
	print('NO')


def equivalent_strings(a, b):
	if a == b:
		return True
	if len(a) % 2 != 0:
		return False
	middle = len(a) // 2
	left_a = a[:middle]
	right_a = a[middle:]
	left_b = b[:middle]
	right_b = b[middle:]
	return equivalent_strings(left_a, right_b) and equivalent_strings(right_a, left_b) or (equivalent_strings(left_a, left_b) and equivalent_strings(right_a, right_b))
a = input()
b = input()
if equivalent_strings(a, b):
	print('YES')
else:
	print('NO')


def merge(parte1, parte2):
	if parte1 < parte2:
		return f'{parte1}{parte2}'
	return f'{parte2}{parte1}'

def divide(paravra):
	tamanho = len(paravra)
	if tamanho % 2 == 1:
		return paravra
	centro = tamanho // 2
	parte1 = divide(paravra[:centro])
	parte2 = divide(paravra[centro:])
	return merge(parte1, parte2)
palavra1 = input()
palavra2 = input()
palavra1 = divide(palavra1)
palavra2 = divide(palavra2)
if palavra1 == palavra2:
	print('YES')
else:
	print('NO')


def compS(s):
	t = len(s)
	if t % 2 == 1:
		return s
	t //= 2
	a = compS(s[0:t])
	b = compS(s[t:])
	return a + b if a < b else b + a
(a, b) = (input(), input())
print('YES' if compS(a) == compS(b) else 'NO')


def sim(x):
	if len(x) % 2:
		return x
	x1 = sim(x[:len(x) // 2])
	x2 = sim(x[len(x) // 2:])
	return x1 + x2 if x1 < x2 else x2 + x1
print('YES' if sim(input()) == sim(input()) else 'NO')


palavra1 = input()
palavra2 = input()
n = len(palavra1)

def sort_string(word):
	if len(word) % 2 == 1:
		return word
	left = sort_string(word[:len(word) // 2])
	right = sort_string(word[len(word) // 2:len(word)])
	return left + right if left < right else right + left
palavra1 = sort_string(palavra1)
palavra2 = sort_string(palavra2)
print('Yes' if palavra1 == palavra2 else 'No')


str1 = input()
str2 = input()
saved = {}

def str_equal(str1, str2):
	if (str1, str2) in saved:
		return saved[str1, str2]
	elif str1 == str2:
		val = True
	elif len(str1) % 2 == 1:
		val = False
	else:
		new_len = len(str1) // 2
		val = str_equal(str1[:new_len], str2[:new_len]) and str_equal(str1[new_len:], str2[new_len:]) or (str_equal(str1[:new_len], str2[new_len:]) and str_equal(str1[new_len:], str2[:new_len]))
	saved[str1, str2] = val
	return val
print('YES' if str_equal(str1, str2) else 'NO')


import sys
import os.path

def judge(strA, strB):
	if strA == strB:
		return True
	length = len(strA)
	half_len = length >> 1
	if length & 1 == 0:
		a1 = strA[:half_len]
		a2 = strA[half_len:]
		b1 = strB[:half_len]
		b2 = strB[half_len:]
		return judge(a1, b1) and judge(a2, b2) or (judge(a2, b1) and judge(a1, b2))
	return False
if os.path.isfile('in.txt'):
	sys.stdin = open('in.txt', 'r', encoding='utf-8')
if judge(input(), input()):
	print('YES')
else:
	print('NO')


def dividir(palavra):
	tamanho = len(palavra)
	if tamanho % 2 == 1:
		return palavra
	tamanho = tamanho // 2
	lado_esquerdo = dividir(palavra[:tamanho])
	lado_direito = dividir(palavra[tamanho:])
	if lado_esquerdo < lado_direito:
		return lado_esquerdo + lado_direito
	else:
		return lado_direito + lado_esquerdo
(palavra1, palavra2) = (input(), input())
print('YES' if dividir(palavra1) == dividir(palavra2) else 'NO')


def solve2(s, l):
	if l % 2:
		return s
	mid = l // 2
	s1 = solve2(s[:mid], mid)
	s2 = solve2(s[mid:], mid)
	return s1 + s2 if s1 < s2 else s2 + s1

def solution():
	s1 = input()
	s2 = input()
	n = len(s1)
	res1 = solve2(s1, n)
	res2 = solve2(s2, n)
	if res1 == res2:
		print('YES')
	else:
		print('NO')
solution()


def equivalencia(letras):
	if len(letras) % 2:
		return letras
	letras_1 = equivalencia(letras[:len(letras) // 2])
	letras_2 = equivalencia(letras[len(letras) // 2:])
	if letras_1 < letras_2:
		retorno = letras_1 + letras_2
	else:
		retorno = letras_2 + letras_1
	return retorno
letras_1 = str(input())
letras_2 = str(input())
equivalentes = equivalencia(letras_1) == equivalencia(letras_2)
if equivalentes:
	print('Yes')
else:
	print('NO')


import sys, os, io
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = 1

def fun(s):
	if len(s) % 2 == 1:
		return s
	n = len(s)
	a = fun(s[:n // 2])
	b = fun(s[n // 2:])
	return min(a, b) + max(a, b)
for _ in range(t):
	a = list(si())
	b = list(si())
	if fun(a) == fun(b):
		print('YES')
	else:
		print('NO')


from functools import lru_cache
from sys import stdin

@lru_cache(maxsize=16)
def solve2(s: str) -> str:
	if len(s) % 2:
		return s
	mid = len(s) // 2
	s1 = solve2(s[:mid])
	s2 = solve2(s[mid:])
	return s1 + s2 if s1 < s2 else s2 + s1

def solution():
	input = stdin.readline
	s1 = input().strip()
	s2 = input().strip()
	n1 = len(s1)
	n2 = len(s2)
	if n1 != n2:
		print('NO')
	elif s1 == s2:
		print('YES')
	else:
		res1 = solve2(s1)
		res2 = solve2(s2)
		if res1 == res2:
			print('YES')
		else:
			print('NO')
solution()


def le(s):
	if len(s) % 2 != 0:
		return s
	l = len(s)
	l1 = l // 2
	t = le(s[:l1])
	t1 = le(s[l1:])
	if t < t1:
		return t + t1
	else:
		return t1 + t
s = input()
s1 = input()
if s == s1:
	print('YES')
else:
	x = le(s)
	y = le(s1)
	if x == y:
		print('YES')
	else:
		print('NO')


def verifica(string):
	tamanho = len(string)
	if tamanho % 2 == 1:
		return string
	aux1 = verifica(string[:tamanho // 2])
	aux2 = verifica(string[tamanho // 2:])
	if aux1 < aux2:
		return aux1 + aux2
	return aux2 + aux1
entradaA = input()
entradaB = input()
if verifica(entradaA) == verifica(entradaB):
	print('YES')
else:
	print('NO')


from sys import stdin
memo = dict()

def equiv(s1, s2):
	if s1 == s2:
		return True
	if len(s1) % 2 == 1:
		return False
	if (s1, s2) in memo:
		return memo[s1, s2]
	if equiv(s1[:int(len(s1) / 2)], s2[:int(len(s2) / 2)]) and equiv(s1[int(len(s1) / 2):], s2[int(len(s2) / 2):]):
		memo[s1, s2] = True
		return True
	if equiv(s1[:int(len(s1) / 2)], s2[int(len(s2) / 2):]) and equiv(s1[int(len(s1) / 2):], s2[:int(len(s2) / 2)]):
		memo[s1, s2] = True
		return True
	memo[s1, s2] = False
	return False
a = stdin.readline().rstrip('\n')
b = stdin.readline().rstrip('\n')
if equiv(a, b):
	print('YES')
else:
	print('NO')


def mini(s):
	m = len(s)
	if m % 2 == 1:
		return s
	m //= 2
	a = mini(s[:m])
	b = mini(s[m:])
	return a + b if a < b else b + a
(a, b) = (input(), input())
print('YES' if mini(a) == mini(b) else 'NO')


def eqv(a, b):
	if a == b:
		return True
	if len(a) != len(b):
		return False
	if len(a) % 2 == 1:
		return False
	metade = len(a) // 2
	a1 = a[:metade]
	b1 = b[:metade]
	a2 = a[metade:]
	b2 = b[metade:]
	return eqv(a1, b2) and eqv(a2, b1) or (eqv(a1, b1) and eqv(a2, b2))
a = input()
b = input()
if eqv(a, b):
	print('YES')
else:
	print('NO')


def reorder(a):
	length = len(a)
	if length % 2 == 1:
		return a
	else:
		p_a = reorder(a[:length // 2])
		s_a = reorder(a[length // 2:])
		if p_a < s_a:
			return p_a + s_a
		else:
			return s_a + p_a
if reorder(input()) == reorder(input()):
	print('YES')
else:
	print('NO')


def lex_small(s):
	n = len(s)
	if n % 2 == 1:
		return s
	a1 = lex_small(s[:n // 2])
	a2 = lex_small(s[n // 2:])
	if a1 < a2:
		return a1 + a2
	return a2 + a1
if lex_small(input()) == lex_small(input()):
	print('YES')
else:
	print('NO')


def check(s):
	if len(s) % 2 == 1:
		return s
	m = int(len(s) / 2)
	l = check(s[:m])
	r = check(s[m:])
	if l < r:
		return l + r
	else:
		return r + l
a = input()
b = input()
if check(a) == check(b):
	print('YES')
else:
	print('NO')


import unittest
import sys

class Strings:

	def __init__(self, args):
		(self.stra, self.strb) = args

	def splitcheck(self, a, b):
		la = a[1] - a[0]
		lb = b[1] - b[0]
		if la != lb or la == 0:
			return 0
		if la % 2 == 1:
			for i in range(la):
				if self.stra[a[0] + i] != self.strb[b[0] + i]:
					return 0
			return 1
		if la == 2:
			(a0, a1) = (self.stra[a[0]], self.stra[a[1] - 1])
			(b0, b1) = (self.strb[b[0]], self.strb[b[1] - 1])
			return a0 == b0 and a1 == b1 or (a0 == b1 and a1 == b0)
		if la == 4:
			(a0, a1, a2, a3) = list(self.stra[a[0]:a[1]])
			(b0, b1, b2, b3) = list(self.strb[b[0]:b[1]])
			answ = (a0 == b0 and a1 == b1 or (a0 == b1 and a1 == b0)) and (a2 == b2 and a3 == b3 or (a2 == b3 and a3 == b2)) or ((a0 == b2 and a1 == b3 or (a0 == b3 and a1 == b2)) and (a2 == b0 and a3 == b1 or (a2 == b1 and a3 == b0)))
			return answ
		mida = (a[0] + a[1]) // 2
		midb = (b[0] + b[1]) // 2
		(a1, a2) = ((mida, a[1]), (a[0], mida))
		(b1, b2) = ((midb, b[1]), (b[0], midb))
		if self.splitcheck(a1, b1) and self.splitcheck(a2, b2):
			return 1
		if self.splitcheck(a1, b2) and self.splitcheck(a2, b1):
			return 1
		return 0

	def calculate(self):
		result = self.splitcheck((0, len(self.stra)), (0, len(self.strb)))
		return str('YES' if result else 'NO')

def get_inputs(test_inputs=None):
	it = iter(test_inputs.split('\n')) if test_inputs else None

	def uinput():
		if it:
			return next(it)
		else:
			return sys.stdin.readline().rstrip()
	stra = uinput()
	strb = uinput()
	return [stra, strb]

def calculate(test_inputs=None):
	return Strings(get_inputs(test_inputs)).calculate()

class unitTests(unittest.TestCase):

	def test_Strings_class__basic_functions(self):
		d = Strings(['aaaabbbb', 'ababbaba'])
		self.assertEqual(d.stra, 'aaaabbbb')
		self.assertEqual(d.splitcheck((0, 1), (0, 1)), 1)
		self.assertEqual(d.splitcheck((3, 4), (0, 2)), 0)
		self.assertEqual(d.splitcheck((3, 6), (0, 3)), 0)
		self.assertEqual(d.splitcheck((3, 5), (1, 3)), 1)
		d.stra = 'abcdefgh'
		d.strb = 'efhgdcba'
		self.assertEqual(d.splitcheck((0, 8), (0, 8)), 1)

	def test_sample_tests(self):
		test = 'aaba\nabaa'
		self.assertEqual(calculate(test), 'YES')
		self.assertEqual(get_inputs(test)[0], 'aaba')
		self.assertEqual(get_inputs(test)[1], 'abaa')
		test = 'aabb\nabab'
		self.assertEqual(calculate(test), 'NO')
		test = 'abddbbdd\nddbbddba'
		self.assertEqual(calculate(test), 'YES')
		test = 'aabb\nbbaa'
		self.assertEqual(calculate(test), 'YES')
		test = 'abddbbdd\nsdbbddba'
		self.assertEqual(calculate(test), 'NO')

	def test_time_limit_test(self):
		import random
		imax = 262144
		numnums = ['abcdcdab' for i in range(imax // 8)]
		test = ''.join(numnums) + '\n'
		line2 = ''.join(numnums)[::-1]
		line2 = line2[:len(line2) - 1] + 't'
		test += line2 + '\n'
		import timeit
		start = timeit.default_timer()
		args = get_inputs(test)
		init = timeit.default_timer()
		d = Strings(args)
		calc = timeit.default_timer()
		print(d.calculate())
		stop = timeit.default_timer()
		print('\nTime Test: ' + '{0:.3f}s (inp {1:.3f}s init {2:.3f}s calc {3:.3f}s)'.format(stop - start, init - start, calc - init, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(calculate())


def rec(str):
	if len(str) % 2:
		return str
	le = len(str)
	le //= 2
	dp1 = rec(str[:le])
	dp2 = rec(str[le:])
	if dp1 < dp2:
		return dp1 + dp2
	return dp2 + dp1
(a, b) = (input(), input())
str1 = rec(a)
str2 = rec(b)
if str1 == str2:
	print('YES')
else:
	print('NO')


def equals(a, b):
	if a == b:
		return True
	(len_a, len_b) = (len(a), len(b))
	if len_a & 1 or len_b & 1:
		return False
	if len_a == 1:
		return False
	as1 = a[0:len_a // 2]
	as2 = a[len_a // 2:len_a // 2 * 2]
	bs1 = b[:len_b // 2]
	bs2 = b[len_b // 2:len_b // 2 * 2]
	return equals(as1, bs2) and equals(as2, bs1) or (equals(as1, bs1) and equals(as2, bs2))
s1 = input()
s2 = input()
if equals(s1, s2):
	print('YES')
else:
	print('NO')


a = input()
b = input()

def solve(string):
	if len(string) % 2 != 0:
		return string
	mid = len(string) // 2
	l_string = solve(string[:mid])
	r_string = solve(string[mid:])
	if l_string + r_string > r_string + l_string:
		return l_string + r_string
	else:
		return r_string + l_string
if solve(a) == solve(b):
	print('YES')
else:
	print('NO')


def equivalent_strings(palavra1, palavra2):
	if palavra1 == palavra2:
		return True
	if len(palavra1) <= 1 and len(palavra2) <= 1:
		return False
	if len(palavra1) % 2 != 0:
		return False
	tamanho_metade = int(len(palavra1) / 2)
	metade1_1 = palavra1[0:tamanho_metade]
	metade1_2 = palavra1[tamanho_metade:len(palavra1)]
	metade2_1 = palavra2[0:tamanho_metade]
	metade2_2 = palavra2[tamanho_metade:len(palavra2)]
	reposta = equivalent_strings(metade1_2, metade2_1) and equivalent_strings(metade1_1, metade2_2)
	if reposta == True:
		return True
	else:
		reposta = equivalent_strings(metade1_1, metade2_1) and equivalent_strings(metade1_2, metade2_2)
		return reposta
s1 = input()
s2 = input()
if equivalent_strings(s1, s2) == True:
	print('YES')
else:
	print('NO')