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