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