#include <bits/stdc++.h>
using namespace std;
string str(string a) {
  if (a.size() % 2 == 1) return a;
  string s3, s4;
  s3 = str(a.substr(0, a.size() / 2));
  s4 = str(a.substr(a.size() / 2, a.size()));
  return min(s3, s4) + max(s3, s4);
}
int main() {
  ios_base::sync_with_stdio(0);
  string a, b;
  cin >> a >> b;
  a = str(a);
  b = str(b);
  if (a == b)
    cout << "YES";
  else
    cout << "NO";
}
