#include <bits/stdc++.h>
using namespace std;
const int N = 302000;
string s, t;
string get(string z) {
  if (z.size() % 2) return z;
  string s1, s2, g = "", g1 = "";
  for (int i = 0; i < z.size() / 2; i++) g += z[i];
  for (int i = z.size() / 2; i < z.size(); i++) g1 += z[i];
  s1 = get(g);
  s2 = get(g1);
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s >> t;
  s = get(s);
  t = get(t);
  if (s == t)
    cout << "YES";
  else {
    cout << "NO";
  }
}
