#include <bits/stdc++.h>
using namespace std;
string least(string ax) {
  if (ax.size() <= 1) return ax;
  int mid = ax.size() / 2;
  if (mid % 2 == 1) {
    string l = ax.substr(0, mid), r = ax.substr(mid, ax.size() - 1);
    if (l < r) return (l + r);
    return (r + l);
  }
  string l = least(ax.substr(0, mid)), r = least(ax.substr(mid, ax.size() - 1));
  if (l < r) return (l + r);
  return (r + l);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  string c = least(a), d = least(b);
  cout << (c == d ? "YES" : "NO") << "\n";
}
