#include <bits/stdc++.h>
using namespace std;
long long powP[200010];
long long preA[200010], preB[200010];
char A[200010], B[200010];
void init() {
  powP[0] = 1LL;
  long long a = 1LL;
  for (int i = 1; i <= 200001; i++) {
    a *= 163;
    a %= 1000000007;
    powP[i] = a;
  }
  return;
}
bool equal(int iA, int jA, int iB, int jB) {
  long long Aval = preA[iA] - ((preA[jA + 1] * powP[jA - iA + 1]) % 1000000007);
  Aval = (Aval + 1000000007) % 1000000007;
  long long Bval = preB[iB] - ((preB[jB + 1] * powP[jB - iB + 1]) % 1000000007);
  Bval = (Bval + 1000000007) % 1000000007;
  return Aval == Bval;
}
bool eq(int iA, int jA, int iB, int jB) {
  if (((jA - iA + 1) & 1) and ((jB - iB + 1) & 1)) {
    return equal(iA, jA, iB, jB);
  }
  bool ret = equal(iA, jA, iB, jB);
  if (ret)
    return ret;
  else {
    int midA = (iA + jA) / 2;
    int midB = (iB + jB) / 2;
    bool ret1 = (eq(iA, midA, midB + 1, jB) and eq(midA + 1, jA, iB, midB));
    if (ret1) return true;
    bool ret2 = (eq(iA, midA, iB, midB) and eq(midA + 1, jA, midB + 1, jB));
    if (ret2) return true;
    return false;
  }
}
void solve() {
  scanf("%s %s", A, B);
  int N = strlen(A);
  for (int i = N - 1; i >= 0; i--) {
    if (i < N - 1) preA[i] = (preA[i + 1] * 163) % 1000000007;
    preA[i] += A[i];
    preA[i] %= 1000000007;
  }
  for (int i = N - 1; i >= 0; i--) {
    if (i < N - 1) preB[i] = (preB[i + 1] * 163) % 1000000007;
    preB[i] += B[i];
    preB[i] %= 1000000007;
  }
  if (eq(0, N - 1, 0, N - 1))
    printf("YES\n");
  else
    printf("NO\n");
  return;
}
int main() {
  init();
  solve();
  return 0;
}
