#include <bits/stdc++.h>
using namespace std;
long long f(string x, string y) {
  if (x.size() % 2) return x == y;
  string a, b, c, d;
  long long i;
  long long md = x.size() / 2;
  for (i = 0; i < md; i++) a += x[i];
  for (i = md; i < x.size(); i++) b += x[i];
  for (i = 0; i < md; i++) c += y[i];
  for (i = md; i < y.size(); i++) d += y[i];
  return ((f(a, d) and f(b, c)) or (f(a, c) and f(b, d)));
}
int main() {
  long long i;
  string s, s2;
  cin >> s >> s2;
  if (f(s, s2))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
