#include <bits/stdc++.h>
using namespace std;
string a, b;
size_t len;
bool comp(int ai, int bi, int cnt) {
  if (equal(a.begin() + ai, a.begin() + ai + cnt, b.begin() + bi)) return true;
  if (cnt & 1) return false;
  return (comp(ai, bi + cnt / 2, cnt / 2) && comp(ai + cnt / 2, bi, cnt / 2)) ||
         (comp(ai, bi, cnt / 2) && comp(ai + cnt / 2, bi + cnt / 2, cnt / 2));
}
int main() {
  cin >> a >> b;
  len = a.size();
  if (comp(0, 0, len))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
