#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
char x[MAX], y[MAX];
bool equiv(int a, int b, int c, int d) {
  assert(b - a == d - c);
  if (a > b) return 1;
  int bad = 0;
  for (int i = a, j = c; i <= b; i++, j++) {
    if (x[i] != y[j]) {
      bad = 1;
      break;
    }
  }
  if (!bad) return 1;
  if ((b - a + 1) % 2 == 1) return 0;
  int m1 = (a + b) / 2;
  int m2 = (c + d) / 2;
  return (equiv(a, m1, c, m2) && equiv(m1 + 1, b, m2 + 1, d)) ||
         (equiv(a, m1, m2 + 1, d) && equiv(m1 + 1, b, c, m2));
}
int main() {
  scanf("%s%s", x + 1, y + 1);
  int n = strlen(x + 1);
  printf(equiv(1, n, 1, n) ? "YES\n" : "NO\n");
  return 0;
}
