#include <bits/stdc++.h>
using namespace std;
string fun(string a) {
  int n = a.length();
  if (n % 2) return a;
  string k = fun(a.substr(0, n / 2));
  string l = fun(a.substr(n / 2));
  return min(k + l, l + k);
}
void solve() {
  string a, b;
  cin >> a >> b;
  int n = a.length();
  bool flag = (fun(a) == fun(b));
  if (flag) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
