#include <bits/stdc++.h>
using namespace std;
string sortStr(string s) {
  if (s.size() % 2 == 1) return s;
  string p1 = sortStr(s.substr(0, s.size() / 2));
  string p2 = sortStr(s.substr(s.size() / 2));
  if (p1 < p2)
    return p1 + p2;
  else
    return p2 + p1;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  string p1 = sortStr(s1);
  string p2 = sortStr(s2);
  if (p1 == p2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
