#include <bits/stdc++.h>
using std::swap;
const int bs = 13131, N = 200005;
char s1[N], s2[N];
int n;
unsigned long long h1[N], h2[N], pw[N];
unsigned long long gt(int l, int r, unsigned long long *hs) {
  return hs[r] - hs[l - 1] * pw[r - l + 1];
}
unsigned long long mrg(int l, int r, unsigned long long *hs, char *s) {
  if ((r - l + 1) & 1) return gt(l, r, hs);
  int m = (l + r) >> 1;
  unsigned long long t1 = mrg(l, m, hs, s), t2 = mrg(m + 1, r, hs, s);
  for (int i = l; i <= m; i++)
    if (s[i] != s[i - l + m + 1]) {
      if (s[i] < s[i - l + m + 1]) return t1 * pw[r - m] + t2;
      for (int j = l; j <= m; j++) swap(s[j], s[j - l + m + 1]);
      return t2 * pw[r - m] + t1;
    }
  return t1 * pw[r - m] + t2;
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1), n = strlen(s1 + 1), pw[0] = 1;
  for (int i = 1; i <= n; i++)
    h1[i] = h1[i - 1] * bs + s1[i], h2[i] = h2[i - 1] * bs + s2[i],
    pw[i] = pw[i - 1] * bs;
  puts(mrg(1, n, h1, s1) == mrg(1, n, h2, s2) ? "YES" : "NO");
  return 0;
}
