#include <bits/stdc++.h>
using namespace std;
string slc(string a, int l, int r) {
  string ans = "";
  for (long long i = l; i < r; ++i) {
    ans += a[i];
  }
  return ans;
}
string smallest(string a, int l) {
  if (l % 2) {
    return a;
  }
  string k1 = slc(a, 0, l / 2), k2 = slc(a, l / 2, l);
  string b = smallest(k1, l / 2);
  string c = smallest(k2, l / 2);
  if (b <= c) return b + c;
  return c + b;
}
signed main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (smallest(s1, s1.length()) == smallest(s2, s2.length())) {
    cout << "YES";
  } else
    cout << "NO";
}
