#include <bits/stdc++.h>
using namespace std;
char s1[200010], s2[200010];
int equal(int p1, int p2, int len) {
  int ok = 1;
  for (int i = p1, j = p2, k = 1; k <= len; ++k, ++i, ++j)
    if (s1[i] != s2[j]) {
      ok = 0;
      break;
    }
  if (ok) return 1;
  if (len & 1) return 0;
  return (equal(p1, p2, len / 2) &&
          equal(p1 + len / 2, p2 + len / 2, len / 2)) ||
         (equal(p1, p2 + len / 2, len / 2) && equal(p1 + len / 2, p2, len / 2));
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  int len = strlen(s1 + 1);
  if (equal(1, 1, len))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
