#include <bits/stdc++.h>
using namespace std;
int sz;
string a, b;
bool solve(int i1, int i2, int l) {
  if (l == 1)
    if (a[i1] == b[i2]) return true;
  bool ok = true;
  for (int i = 0; i < l; i++) {
    if (a[i1 + i] != b[i2 + i]) {
      ok = false;
      break;
    }
  }
  if (ok) return true;
  if (l % 2 == 1) return false;
  int h = l / 2;
  if ((solve(i1, i2 + h, h) && solve(i1 + h, i2, h)) ||
      (solve(i1, i2, h) && solve(i1 + h, i2 + h, h)))
    return true;
  else
    return false;
}
int main() {
  cin >> a >> b;
  sz = a.size();
  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }
  if (sz % 2 == 1) {
    cout << "NO" << endl;
    return 0;
  }
  int half = sz / 2;
  if ((solve(0, half, half) && solve(half, 0, half)) ||
      (solve(0, 0, half) && solve(half, half, half))) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
