#include <bits/stdc++.h>
using namespace std;
string a, b;
bool calc(int l, int r, int tl, int tr) {
  int pos = tl;
  for (int i = l; i <= r; i++) {
    if (a[i] != b[pos]) break;
    pos++;
  }
  if (pos == tr + 1)
    return 1;
  else {
    if ((r - l + 1) % 2 == 0) {
      int mid = (l + r) / 2;
      int mid2 = (tl + tr) / 2;
      if ((calc(l, mid, mid2 + 1, tr) && calc(mid + 1, r, tl, mid2)) ||
          (calc(l, mid, tl, mid2) && calc(mid + 1, r, mid2 + 1, tr)))
        return 1;
    } else
      return 0;
  }
}
int main() {
  cin >> a >> b;
  if (calc(0, a.size() - 1, 0, a.size() - 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
