#include <bits/stdc++.h>
using namespace std;
string find(string s) {
  if ((long long)s.size() & 1) return s;
  long long n = (long long)s.size();
  string left = find(s.substr(0, n / 2));
  string right = find(s.substr(n / 2));
  if (left > right) return right + left;
  return left + right;
}
signed main() {
  ios_base::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  long long n = (long long)s.size();
  if ((long long)t.size() != n) {
    cout << "NO" << endl;
    return 0;
  }
  s = find(s);
  t = find(t);
  if (s == t)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
