#include <bits/stdc++.h>
using namespace std;
char str[2][400000 + 10];
int n;
void sortstr(int t, int l, int r) {
  if ((r - l + 1) & 1) return;
  int md = (l + r) / 2;
  sortstr(t, l, (l + r) / 2), sortstr(t, (l + r) / 2 + 1, r);
  bool needswap = false;
  for (int i = l, j = md + 1; i <= md; i++, j++) {
    if (str[t][i] < str[t][j]) break;
    if (str[t][i] > str[t][j]) {
      needswap = true;
      break;
    }
  }
  if (needswap) {
    for (int i = l, j = md + 1; i <= md; i++, j++) swap(str[t][i], str[t][j]);
  }
}
int main() {
  for (int i = 0; i < 2; i++)
    scanf("%s", str[i]), n = strlen(str[i]), sortstr(i, 0, n - 1);
  bool equ = true;
  for (int i = 0; i < n; i++)
    if (str[0][i] != str[1][i]) equ = false;
  printf("%s\n", equ ? "YES" : "NO");
  return 0;
}
