#include <bits/stdc++.h>
using namespace std;
string f(string s) {
  int n = s.size();
  if (n & 1) return s;
  string l = s.substr(0, n / 2);
  string r = s.substr(n / 2);
  l = f(l);
  r = f(r);
  if (l > r) return r + l;
  return l + r;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  s1 = f(s1);
  s2 = f(s2);
  if (s1 == s2)
    cout << "YES";
  else
    cout << "NO";
}
