#include <bits/stdc++.h>
using namespace std;
string divAndConq(string sip) {
  if (sip.size() % 2 == 1) return sip;
  string s1 = divAndConq(string(sip.begin(), sip.begin() + sip.size() / 2));
  string s2 = divAndConq(string(sip.begin() + sip.size() / 2, sip.end()));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  string a, b;
  cin >> a;
  cin >> b;
  if (divAndConq(a) == divAndConq(b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
