#include <bits/stdc++.h>
using namespace std;
unsigned long long p[250005], h1[250005], h2[250005];
unsigned long long ch(unsigned long long a1, unsigned long long a2,
                      unsigned long long b1, unsigned long long b2) {
  unsigned long long v1 = h1[a2] - (h1[a1 - 1] * p[a2 - a1 + 1]);
  unsigned long long v2 = h2[b2] - (h2[b1 - 1] * p[b2 - b1 + 1]);
  return (v1 == v2);
}
unsigned long long rec(unsigned long long ax, unsigned long long ay,
                       unsigned long long bx, unsigned long long by) {
  if (((ay - ax + 1) % 2 == 1) && ((by - bx + 1) % 2 == 1)) {
    return ch(ax, ay, bx, by);
  }
  if (ch(ax, ay, bx, by)) return 1;
  unsigned long long m1 = (ax + ay) / 2;
  unsigned long long m2 = (bx + by) / 2;
  if (rec(ax, m1, m2 + 1, by) && rec(m1 + 1, ay, bx, m2)) return 1;
  if (rec(ax, m1, bx, m2) && rec(m1 + 1, ay, m2 + 1, by)) return 1;
  return 0;
}
int main() {
  unsigned long long i, j, k, n, m, t;
  string a, b;
  cin >> a >> b;
  p[0] = 1;
  for (i = 1; i <= a.size(); i++) {
    p[i] = (p[i - 1] * 31);
  }
  for (i = 0; i < b.size(); i++) {
    h2[i + 1] = (h2[i] * 31 + (b[i] - 96));
  }
  for (i = 0; i < a.size(); i++) {
    h1[i + 1] = (h1[i] * 31 + (a[i] - 96));
  }
  n = a.size();
  if (rec(1, n, 1, n))
    cout << "YES\n";
  else
    cout << "NO\n";
}
