#include <bits/stdc++.h>
using namespace std;
char s1[200001];
char s2[200001];
bool pan(int l, int r, int ll, int rr) {
  bool ok = true;
  for (int i = l, j = ll; i < r && j < rr; i++, j++) {
    if (s1[i] != s2[j]) {
      ok = false;
      break;
    }
  }
  if (ok) return true;
  if ((r - l) & 1) return false;
  if (pan(l, (l + r) / 2, ll, (rr + ll) / 2) &&
      pan((l + r) / 2, r, (rr + ll) / 2, rr))
    return true;
  if (pan(l, (l + r) / 2, (rr + ll) / 2, rr) &&
      pan((l + r) / 2, r, ll, (rr + ll) / 2))
    return true;
  return false;
}
bool check(int l, int r, int ll, int rr) {
  bool ok = true;
  for (int i = l, j = ll; i < r && j < rr; i++, j++) {
    if (s1[i] != s2[j]) {
      ok = false;
      break;
    }
  }
  if (ok) return true;
  if ((r - l) & 1) return false;
  int m = (l + r) >> 1, mm = (ll + rr) >> 1;
  return (check(l, m, ll, mm) && check(m, r, mm, rr)) ||
         (check(l, m, mm, rr) && check(m, r, ll, mm));
}
void work() {
  int l1, l2;
  l1 = strlen(s1);
  l2 = strlen(s2);
  if (l1 != l2) {
    printf("NO");
    return;
  }
  if (check(0, l1, 0, l2)) {
    printf("YES");
    return;
  }
  printf("NO");
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  work();
  return 0;
}
