#include <bits/stdc++.h>
using namespace std;
char A[200005];
char B[200005];
bool equival(int ai, int af, int bi, int bf) {
  if (af - ai != bf - bi) return false;
  bool band = true;
  for (int i = 0; i + ai <= af; i++)
    if (A[ai + i] != B[bi + i]) {
      band = false;
      break;
    }
  if (band) return true;
  if (af == ai) return A[ai] == B[bi];
  int mit1 = (ai + af) / 2;
  int mit2 = (bi + bf) / 2;
  if ((bf - bi + 1) % 2) return false;
  if (equival(ai, mit1, bi, mit2) && equival(mit1 + 1, af, mit2 + 1, bf))
    return true;
  if (equival(ai, mit1, mit2 + 1, bf) && equival(mit1 + 1, af, bi, mit2))
    return true;
  return false;
}
int main() {
  cin.tie();
  ios_base::sync_with_stdio(false);
  scanf("%s%s", A + 1, B + 1);
  int n = strlen(A + 1);
  if (equival(1, n, 1, n))
    printf("YES");
  else
    printf("NO");
  return 0;
}
