#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string s, t;
string solve(string s) {
  if (s.size() % 2) return s;
  string l = solve(s.substr(0, s.size() / 2));
  string r = solve(s.substr(s.size() / 2, s.size() / 2));
  return (l <= r) ? l + r : r + l;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> s >> t;
  s = solve(s);
  t = solve(t);
  if (s == t)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
