#include <bits/stdc++.h>
using namespace std;
string solve(string a) {
  if (a.size() % 2 == 1) return a;
  string halfA(a.begin(), a.begin() + (a.size() / 2));
  string halfB(a.begin() + (a.size() / 2), a.end());
  string A = solve(halfA);
  string B = solve(halfB);
  return A < B ? A + B : B + A;
}
int main() {
  ios_base::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  a = solve(a);
  b = solve(b);
  cout << (a == b ? "YES" : "NO") << endl;
  return 0;
}
