a = raw_input()
b = raw_input()

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