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