#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000100;
const int INF = (1 << 29);
const double EPS = 0.0000000001;
const double Pi = acos(-1.0);
char a[maxn], b[maxn];
bool jud(char *a, char *b, int L) {
  bool flag = 1;
  for (int(i) = (0); (i) <= (L - 1); (i)++) {
    if (a[i] != b[i]) {
      flag = 0;
      break;
    }
  }
  if (flag) return 1;
  if (L % 2) return 0;
  L /= 2;
  return (jud(a, b, L) && jud(a + L, b + L, L)) ||
         (jud(a, b + L, L) && jud(a + L, b, L));
}
int main() {
  while (~scanf("%s%s", a, b)) {
    puts(jud(a, b, strlen(a)) ? "YES" : "NO");
  }
  return 0;
}
