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