#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 256;
const char nxt = '\n';
inline void in(string Q) {
  Q += ".in";
  freopen(Q.c_str(), "r", stdin);
}
inline void out(string Q) {
  Q += ".out";
  freopen(Q.c_str(), "w", stdout);
}
inline void open_file(string Q) {
  in(Q);
  out(Q);
}
string q, w;
string smallest(string s) {
  if (s.length() % 2 == 1) return s;
  string s1 = smallest(s.substr(0, s.length() / 2));
  string s2 = smallest(s.substr(s.length() / 2, s.length()));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  if (0) open_file("");
  cin >> q >> w;
  if (smallest(q) == smallest(w))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
