#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n;
char a[MAXN], b[MAXN];
int cmp(char s1[], char s2[], int len) {
  int ok = 1;
  for (int i = 0; i < len; i++)
    if (s1[i] != s2[i]) ok = 0;
  return ok;
}
int equ(char x[], char y[], int len) {
  if (cmp(x, y, len)) return 1;
  if (len % 2 == 0)
    return (equ(x, y + len / 2, len / 2) && equ(x + len / 2, y, len / 2)) ||
           (equ(x, y, len / 2) && equ(x + len / 2, y + len / 2, len / 2));
  return 0;
}
int main() {
  while (cin >> a >> b) {
    int len = strlen(a);
    equ(a, b, len) == 1 ? puts("YES") : puts("NO");
  }
}
