#include <bits/stdc++.h>
using namespace std;
char a[200005], b[200005];
int chk(char* a1, char* b1, int l) {
  bool flag = 0;
  for (int i = 0; i < l; i++) {
    if (a1[i] != b1[i]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) return 1;
  if (l % 2 == 1) return 0;
  return (chk(a1, b1, l / 2) && chk(a1 + l / 2, b1 + l / 2, l / 2)) ||
         (chk(a1, b1 + l / 2, l / 2) && chk(a1 + l / 2, b1, l / 2));
}
int main() {
  while (scanf("%s%s", a, b) != EOF) {
    if (chk(a, b, strlen(b)))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
