#include <bits/stdc++.h>
using namespace std;
string SUBSTR(string X) {
  int len = X.length();
  if (len % 2) return X;
  string X1 = SUBSTR(X.substr(0, len / 2));
  string X2 = SUBSTR(X.substr(len / 2));
  return min(X1 + X2, X2 + X1);
}
int main() {
  string A, B;
  cin >> A >> B;
  if (SUBSTR(A) == SUBSTR(B))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
