#include <bits/stdc++.h>
char a[200005], b[200005];
int len;
bool solve(int as, int ae, int bs, int be) {
  if ((ae - as) % 2 == 0) {
    int i;
    for (i = 0; i <= ae - as; i++) {
      if (a[as + i] != b[bs + i]) {
        return false;
      }
    }
    return true;
  } else {
    int apiv = (as + ae) / 2, bpiv = (bs + be) / 2;
    if (solve(as, apiv, bs, bpiv) && solve(apiv + 1, ae, bpiv + 1, be))
      return true;
    if (solve(as, apiv, bpiv + 1, be) && solve(apiv + 1, ae, bs, bpiv))
      return true;
    return false;
  }
}
int main() {
  scanf("%s%s", &a, &b);
  len = strlen(a);
  printf("%s", solve(0, len - 1, 0, len - 1) ? "YES" : "NO");
}
