#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <class T>
auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
  out << "{";
  bool f = 1;
  for (auto &a : x) {
    if (!f) out << ", ";
    out << a;
    f = 0;
  }
  return out << "}";
}
template <class T>
void __f(const char *a, T &&t) {
  cerr << a << ": " << t << endl;
}
template <class A, class... B>
void __f(const char *n, A &&a, B &&...b) {
  const char *c = strchr(n + 1, ',');
  cerr.write(n, c - n) << ": " << a << " |";
  __f(c + 1, b...);
}
using ll = long long;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;
string s, t;
int n;
string solve(string str) {
  int l = (int)(str).size();
  if (l & 1) return str;
  int h = l / 2;
  string a = solve(str.substr(0, h));
  string b = solve(str.substr(h, h));
  return ((a < b) ? a + b : b + a);
}
signed main() {
  cin >> s >> t;
  string a = solve(s);
  string b = solve(t);
  cout << (a == b ? "YES" : "NO") << '\n';
}
