#include <bits/stdc++.h>
using namespace std;
string s, s2;
long long f(long long a, long long b, long long x, long long y) {
  if ((b - a) % 2) {
    long long i, j;
    bool f = 1;
    for (i = a, j = x; i < b; i++, j++)
      if (s[i] != s2[j]) f = 0;
    return f;
  }
  long long md = (a + b) / 2;
  long long md2 = (x + y) / 2;
  return ((f(a, md, md2, y) and f(md, b, x, md2)) or
          (f(a, md, x, md2) and f(md, b, md2, y)));
}
int main() {
  long long i;
  cin >> s >> s2;
  if (f(0, s.size(), 0, s2.size()))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
