#include <bits/stdc++.h>
using namespace std;
const int L = 200000;
const unsigned int MAGIC1 = 10007;
const unsigned int MAGIC2 = 127;
char s[L + 5], t[L + 5];
unsigned int sh1[L + 5], th1[L + 5], base1[L + 5];
unsigned int sh2[L + 5], th2[L + 5], base2[L + 5];
int n;
inline void init_hash(unsigned int h[], char s[], unsigned int base[]) {
  h[0] = 0;
  for (int i = 1; i <= n; i++) h[i] = h[i - 1] * base[1] + s[i - 1];
}
inline unsigned int gethash(unsigned int h[], int l, int r,
                            unsigned int base[]) {
  r++;
  return h[r] - h[l] * base[r - l];
}
inline bool ok(int L1, int R1, int L2, int R2) {
  return gethash(sh1, L1, R1, base1) == gethash(th1, L2, R2, base1) &&
         gethash(sh2, L1, R1, base2) == gethash(th2, L2, R2, base2);
}
bool check(int L1, int R1, int L2, int R2) {
  int len = R1 - L1 + 1;
  if (ok(L1, R1, L2, R2)) return 1;
  if (len & 1) return 0;
  int hlen = len >> 1;
  return (check(L1, R1 - hlen, L2 + hlen, R2) &&
          check(L1 + hlen, R1, L2, R2 - hlen)) ||
         (check(L1, R1 - hlen, L2, R2 - hlen) &&
          check(L1 + hlen, R1, L2 + hlen, R2));
}
inline void prepare() {
  base1[0] = base2[0] = 1;
  for (int i = 1; i <= n; i++) {
    base1[i] = base1[i - 1] * MAGIC1;
    base2[i] = base2[i - 1] * MAGIC2;
  }
  init_hash(sh1, s, base1);
  init_hash(sh2, s, base2);
  init_hash(th1, t, base1);
  init_hash(th2, t, base2);
}
int main() {
  scanf("%s", s);
  scanf("%s", t);
  n = strlen(s);
  prepare();
  if (check(0, n - 1, 0, n - 1))
    puts("YES");
  else
    puts("NO");
  return 0;
}
