#include <bits/stdc++.h>
using namespace std;
const int MAXN = 222222;
char a[MAXN], b[MAXN];
inline bool judge(const int l1, const int r1, const int l2, const int r2) {
  bool haveans = true;
  for (int i = 0; l1 + i < r1 && haveans; i++)
    if (a[l1 + i] != b[l2 + i]) haveans = false;
  if (haveans) return true;
  int len1 = r1 - l1, len2 = r2 - l2;
  if ((r1 - l1) & 1) return false;
  if (judge(l1, l1 + (len1 >> 1), l2, l2 + (len2 >> 1)) &&
      judge(l1 + (len1 >> 1), r1, l2 + (len2 >> 1), r2))
    return true;
  if (judge(l1, l1 + (len1 >> 1), l2 + (len2 >> 1), r2) &&
      judge(l1 + (len1 >> 1), r1, l2, l2 + (len2 >> 1)))
    return true;
  return false;
}
int main() {
  gets(a);
  gets(b);
  int len = strlen(a);
  if (judge(0, len, 0, len))
    puts("YES");
  else
    puts("NO");
}
