#include <bits/stdc++.h>
using namespace std;
string a, b;
string f(string s) {
  int l = s.size();
  if (l % 2 == 1) return s;
  string s1 = f(s.substr(0, l / 2)), s2 = f(s.substr(l / 2, l));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  cin >> a >> b;
  if (f(a) == f(b))
    puts("YES");
  else
    puts("NO");
  return 0;
}
