#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)2e5 + 20;
char s[N], t[N];
struct Hash {
  unsigned long long ha[N], p[N];
  unsigned long long base;
  void init(char *s, int len) {
    base = 2333333333333;
    p[0] = 1;
    ha[0] = 0;
    for (int i = (1); i < (N); ++i) p[i] = p[i - 1] * base;
    for (int i = (1); i < (len + 1); ++i) ha[i] = ha[i - 1] * base + s[i];
  }
  unsigned long long qry(int l, int r) {
    return ha[r] - ha[l - 1] * p[r - l + 1];
  }
} s1, t1;
bool check(int sl, int sr, int tl, int tr) {
  int n = sr - sl + 1, m = n / 2;
  bool f = s1.qry(sl, sr) == t1.qry(tl, tr);
  if (n & 1 || f) return f;
  bool f1 =
      check(sl, sl + m - 1, tl + m, tr) && check(sl + m, sr, tl, tl + m - 1);
  if (f1) return true;
  bool f2 =
      check(sl, sl + m - 1, tl, tl + m - 1) && check(sl + m, sr, tl + m, tr);
  if (f2) return true;
  return false;
}
int main() {
  while (~scanf("%s%s", s + 1, t + 1)) {
    int n = strlen(s + 1);
    s1.init(s, n);
    t1.init(t, n);
    bool ans = check(1, n, 1, n);
    if (ans)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
