#include <bits/stdc++.h>
using namespace std;
char a[200005], b[200005];
bool sol(int st, int en, int x, int y) {
  if ((en - st + 1) != (y - x + 1)) return false;
  int sz = en - st + 1;
  if (sz & 1) {
    for (int i = st, j = x; i <= en && j <= y; i++, j++) {
      if (a[i] != b[j]) return false;
    }
    return true;
  }
  int mid = sz / 2;
  bool a, b, c, d;
  a = sol(st, st + mid - 1, x, x + mid - 1);
  if (a == true) {
    b = sol(st + mid, en, x + mid, y);
    if (b == true) return true;
  }
  c = sol(st, st + mid - 1, x + mid, y);
  if (c == true) {
    d = sol(st + mid, en, x, x + mid - 1);
    if (d == true) return true;
  }
  return false;
}
int main() {
  scanf("%s", a);
  scanf("%s", b);
  int l = strlen(a);
  int m = strlen(b);
  bool z;
  z = sol(0, l - 1, 0, m - 1);
  if (z)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
