#include <bits/stdc++.h>
using namespace std;
char s[200000], t[200000];
int equi(int a, int b, int c, int d) {
  bool x = 1;
  for (int i = 0; i <= b - a; i++) {
    x &= (s[i + a] == t[i + c]);
  }
  if (x) return 1;
  if (b <= a) return 0;
  int n = b - a + 1;
  if (n % 2 == 1) return 0;
  if (equi(a, a + n / 2 - 1, c, c + n / 2 - 1)) {
    if (equi(a + n / 2, b, c + n / 2, d)) return 1;
  }
  if (equi(a, a + n / 2 - 1, c + n / 2, d)) {
    if (equi(a + n / 2, b, c, c + n / 2 - 1)) return 1;
  }
  return 0;
}
int main() {
  int n = 0;
  scanf("%s", s);
  scanf("%s", t);
  while (s[n++] != '\0')
    ;
  n--;
  if (equi(0, n - 1, 0, n - 1))
    printf("YES");
  else
    printf("NO");
}
