#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
bool compare(pair<int, int> p1, pair<int, int> p2) {
  return p1.second < p2.first;
}
string ss(string a) {
  int n = a.size();
  if (n & 1) return a;
  string k = ss(a.substr(0, n / 2));
  string l = ss(a.substr(n / 2));
  return min(k + l, l + k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string x, y;
  cin >> x >> y;
  cout << (ss(x) == ss(y) ? "YES" : "NO");
  return 0;
}
