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