#include <bits/stdc++.h>
const int maxn = 200002;
char a[maxn];
char b[maxn];
char c;
void Sort(char *a, int l) {
  if (l == 1) return;
  int r = l;
  int m = l >> 1;
  l = r - m;
  if (m == l) {
    Sort(a, m);
    Sort(a + m, l);
    int i = 0;
    while (i < m && a[i] == a[m + i]) i++;
    if (i == m) return;
    if (a[i] > a[i + m])
      for (int i = 0; i < l; i++) {
        c = a[i];
        a[i] = a[i + l];
        a[i + l] = c;
      }
  }
}
int main() {
  gets(a);
  gets(b);
  int l = strlen(a);
  Sort(a, l);
  Sort(b, l);
  puts(strcmp(a, b) == 0 ? "YES" : "NO");
  return 0;
}
