#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[200001], b[200001];
  scanf("%s%s", a, b);
  int ln = strlen(a);
  auto f = [&](char *s) {
    int lns = ln;
    while (lns % 2 == 0) {
      lns >>= 1;
    }
    for (int i = lns; i + i <= ln; i <<= 1) {
      for (int j = 0; j < ln; j += i + i) {
        for (int jj = j; jj < j + i; jj++) {
          if (s[jj] != s[jj + i]) {
            if (s[jj] > s[jj + i])
              for (int ii = j; ii < j + i; ii++) {
                swap(s[ii], s[ii + i]);
              }
            break;
          }
        }
      }
    }
  };
  f(a);
  f(b);
  if (strcmp(a, b) == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
