#include <bits/stdc++.h>
using namespace std;
string a, b;
bool equal(int ai, int bi, int size) {
  for (int i = 0; i < size; ++i) {
    if (a[ai + i] != b[bi + i]) return false;
  }
  return true;
}
bool solve(int ai, int aj, int bi, int bj) {
  if (equal(ai, bi, aj - ai)) return true;
  if ((aj - ai) % 2 == 0) {
    int mid = (aj - ai) / 2;
    if (solve(ai, ai + mid, bi, bi + mid) && solve(ai + mid, aj, bi + mid, bj))
      return true;
    if (solve(ai, ai + mid, bi + mid, bj) && solve(ai + mid, aj, bi, bi + mid))
      return true;
  }
  return false;
}
int main() {
  cin >> a >> b;
  if (solve(0, a.size(), 0, b.size()))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
