#include <bits/stdc++.h>
using namespace std;
string a, b;
int t;
string ssort(string x) {
  if (x.size() & 1) return x;
  int len = x.size() / 2;
  string xx, yy;
  xx = ssort(x.substr(0, len));
  yy = ssort(x.substr(len, len));
  if (xx < yy)
    return xx + yy;
  else
    return yy + xx;
}
signed main() {
  cin >> a >> b;
  if (a == b) {
    printf("YES\n");
    return 0;
  }
  if (ssort(a) == ssort(b))
    printf("YES\n");
  else
    printf("NO\n");
}
