#include <bits/stdc++.h>
using namespace std;
string rep(string a) {
  if (a.size() % 2) return a;
  string a1(a.begin(), a.begin() + a.size() / 2);
  string a2(a.begin() + a.size() / 2, a.end());
  a1 = rep(a1);
  a2 = rep(a2);
  if (a1 < a2)
    return a1 + a2;
  else
    return a2 + a1;
}
int main() {
  string a, b;
  cin >> a >> b;
  if (rep(a) == rep(b))
    cout << "YES";
  else
    cout << "NO";
}
