#include <bits/stdc++.h>
using namespace std;
string Equivalent(string o1, string o2) {
  if (o1 == o2) return "YES";
  if (o1.size() % 2 == 1) return "NO";
  string ww, ee, rr, tt;
  int w = 0, e = 0, r = 0, t = 0;
  int f = o1.size() / 2;
  for (int i = 0; i < o1.size() / 2; i++)
    w += o1[i], e += o2[i], r += o1[f], t += o2[f], ww += o1[i], ee += o2[i],
        rr += o1[f], tt += o2[f], f++;
  if (Equivalent(ww, tt) == "YES" && Equivalent(ee, rr) == "YES") return "YES";
  if (Equivalent(ww, ee) == "YES" && Equivalent(rr, tt) == "YES") return "YES";
  return "NO";
}
struct q {
  int id;
  int j;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string ss, dd;
  cin >> ss >> dd;
  cout << Equivalent(ss, dd);
  int x;
  cin >> x;
  return 0;
}
