#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5, inf = 998244353;
long long n, k, m, id = 0, z = 31;
string f(string s) {
  if ((long long)s.size() & 1) return s;
  string s1 = f(s.substr(0, (long long)s.size() / 2)),
         s2 = f(s.substr((long long)s.size() / 2, (long long)s.size() / 2));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, a, b, ans = 0;
  string s, t;
  cin >> s >> t;
  if (f(s) == f(t))
    cout << "YES";
  else
    cout << "NO";
}
