#include <bits/stdc++.h>
using namespace std;
char A[201000], B[201000];
bool isequal(int l, int r, int a, int b) {
  int i, j;
  for (i = l, j = a; i <= r; i++, j++)
    if (A[i] != B[j]) return false;
  return true;
}
bool iseqv(int l, int r, int a, int b) {
  if ((r - l + 1) % 2 == 1) return isequal(l, r, a, b);
  if (isequal(l, r, a, b)) return true;
  int m = (l + r) / 2, c = (a + b) / 2;
  return (iseqv(l, m, a, c) && iseqv(m + 1, r, c + 1, b)) ||
         (iseqv(l, m, c + 1, b) && iseqv(m + 1, r, a, c));
}
int main() {
  int len;
  scanf("%s", A);
  scanf("%s", B);
  len = strlen(A) - 1;
  iseqv(0, len, 0, len) ? printf("YES\n") : printf("NO\n");
  return 0;
}
