#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const long long mod = (int)1e8 + 7;
const long long p = 1993;
const int N = (int)3e5;
int n;
char a[N], b[N];
long long ha[N], hb[N], pw[N];
void end(bool yes) {
  puts(yes ? "YES" : "NO");
  exit(0);
}
void precalc() {
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * p;
  for (int i = 0; i < n; i++) {
    ha[i + 1] = ha[i] + pw[i] * (a[i] - 'a' + 1);
    hb[i + 1] = hb[i] + pw[i] * (b[i] - 'a' + 1);
  }
}
bool match(int pa, int push_back, int n) {
  return pw[max(0, push_back - pa)] * (ha[pa + n] - ha[pa]) ==
         (hb[push_back + n] - hb[push_back]) * pw[max(0, pa - push_back)];
}
bool check(int pa, int push_back, int n) {
  if (n & 1) return match(pa, push_back, n);
  n >>= 1;
  int t = rand() & 1;
  if (check(pa + t * n, push_back, n))
    return check(pa + (t ^ 1) * n, push_back + n, n);
  if (check(pa + (t ^ 1) * n, push_back, n))
    return check(pa + t * n, push_back + n, n);
  return false;
}
int main() {
  scanf("%s", a);
  scanf("%s", b);
  n = strlen(a);
  if (strlen(b) != n) end(0);
  precalc();
  end(check(0, 0, n));
  return 0;
}
