#include <bits/stdc++.h>
using namespace std;
bool equiv(const string& a, const string& b) {
  static string _a1, _a2, _b1, _b2;
  if (a == b) return true;
  if (a.size() % 2) return false;
  string a1 = a.substr(0, a.size() / 2), a2 = a.substr(a.size() / 2);
  string b1 = b.substr(0, b.size() / 2), b2 = b.substr(b.size() / 2);
  _a1 = a1, _a2 = a2;
  _b1 = b1, _b2 = b2;
  sort(_a1.begin(), _a1.end());
  sort(_a2.begin(), _a2.end());
  sort(_b1.begin(), _b1.end());
  sort(_b2.begin(), _b2.end());
  const bool f1 = (_a1 == _b1 && _a2 == _b2);
  const bool f2 = (_a1 == _b2 && _a2 == _b1);
  if (f1)
    if (equiv(a1, b1) && equiv(a2, b2)) return true;
  if (f2)
    if (equiv(a1, b2) && equiv(a2, b1)) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  cout << (equiv(a, b) ? "YES" : "NO") << endl;
}
