#include <bits/stdc++.h>
using namespace std;
string solve(string k) {
  if (k.length() % 2) return k;
  string m = solve(k.substr(0, k.length() / 2));
  string n = solve(k.substr(k.length() / 2, k.length()));
  if (m < n) return n + m;
  return m + n;
}
int main() {
  string a, b;
  cin >> a >> b;
  cout << (solve(a) == solve(b) ? "YES" : "NO") << endl;
  return 0;
}
