#include <bits/stdc++.h>
using namespace std;
string inp, inpp;
string div(string a) {
  int sz = a.size();
  if (sz % 2) return a;
  string hav1 = div(a.substr(0, sz / 2));
  string hav2 = div(a.substr(sz / 2, sz / 2));
  return hav1 < hav2 ? hav1 + hav2 : hav2 + hav1;
}
int main() {
  getline(cin, inp);
  getline(cin, inpp);
  cout << ((div(inp) == div(inpp)) ? "YES\n" : "NO\n");
  return 0;
}
