#include <bits/stdc++.h>
using namespace std;
int64_t k = 0;
inline bool equals(string& s1, int64_t i1, int64_t j1, string& s2, int64_t i2,
                   int64_t j2) {
  if (j1 != j2) {
    return false;
  }
  auto x = j1;
  for (int64_t i = 0; i < x; i++) {
    if (s1[i1 + i] != s2[i2 + i]) {
      return false;
    }
  }
  return true;
}
bool equivilant(string& s1, int64_t i1, int64_t j1, string& s2, int64_t i2,
                int64_t j2) {
  if (equals(s1, i1, j1, s2, i2, j2)) {
    return true;
  }
  if (j1 != j2 || j1 % 2 == 1) {
    return false;
  }
  auto x = j1 / 2;
  if (equivilant(s1, i1, x, s2, i2, x) &&
      equivilant(s1, i1 + x, x, s2, i2 + x, x)) {
    return true;
  }
  if (equivilant(s1, i1, x, s2, i2 + x, x) &&
      equivilant(s1, i1 + x, x, s2, i2, x)) {
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  string s1;
  cin >> s1;
  string s2;
  cin >> s2;
  if (equivilant(s1, 0, s1.size(), s2, 0, s2.size())) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
