#include <bits/stdc++.h>
using namespace std;
string s1, s2;
string con(string s, int n) {
  if (n % 2 != 0) return s;
  string t1 = con(s.substr(0, n / 2), n / 2);
  string t2 = con(s.substr(n / 2, n / 2), n / 2);
  if (t1 < t2) return t1 + t2;
  return t2 + t1;
}
int main() {
  cin >> s1 >> s2;
  int n = s1.length();
  s1 = con(s1, n);
  s2 = con(s2, n);
  if (s1 == s2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
