#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 * 100 + 33, mod = 1000 * 1000 * 1000 + 3, mabna = 31;
long long ary[N], a[N], b[N];
int n;
char s[N], t[N];
void var() {
  ary[0] = 1;
  for (int i = 1; i < N; i++) ary[i] = (ary[i - 1] * mabna) % mod;
}
bool ok(int fa, int la, int fb, int lb) {
  long long val1, val2;
  val1 = (a[la] - a[fa] + mod) % mod;
  val2 = (b[lb] - b[fb] + mod) % mod;
  val1 = (val1 * ary[n - fa]) % mod;
  val2 = (val2 * ary[n - fb]) % mod;
  if (val1 == val2) return true;
  if ((la - fa) % 2) return false;
  int mida = (la + fa) / 2, midb = (fb + lb) / 2;
  if (ok(fa, mida, midb, lb) && ok(mida, la, fb, midb)) return true;
  if (ok(fa, mida, fb, midb) && ok(mida, la, midb, lb)) return true;
  return false;
}
int main() {
  scanf("%199999s", s);
  scanf("%199999s", t);
  while ('a' <= s[n] && s[n] <= 'z') n++;
  var();
  for (int i = 0; i < n; i++) {
    a[i + 1] = (a[i] + (s[i] - 'a' + 1) * ary[i]) % mod;
  }
  for (int i = 0; i < n; i++) {
    b[i + 1] = (b[i] + (t[i] - 'a' + 1) * ary[i]) % mod;
  }
  if (ok(0, n, 0, n)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
