#include <bits/stdc++.h>
using namespace std;
string fun(string a) {
  if (a.length() % 2 == 1) {
    return a;
  }
  string b, c;
  for (long long i = 0; i < a.length() / 2; i++) {
    b += a[i];
    c += a[i + a.length() / 2];
  }
  string d = fun(b);
  string e = fun(c);
  return min(d + e, e + d);
}
void solve() {
  string a, b;
  cin >> a >> b;
  if (fun(a) == fun(b)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
