#include <bits/stdc++.h>
using namespace std;
string left(string s) { return s.substr(0, s.length() / 2); }
string right(string s) { return s.substr(s.length() / 2, s.length() - 1); }
bool check(string s1, string s2) {
  if (s1.length() % 2 == 1 && s2.length() % 2 == 1) return s1 == s2;
  if (s1 == s2) return 1;
  string l1 = left(s1);
  string r1 = right(s1);
  string l2 = left(s2);
  string r2 = right(s2);
  return ((check(l1, r2) && check(l2, r1)) || (check(l1, l2) && check(r1, r2)));
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  check(s1, s2) ? cout << "YES\n" : cout << "NO\n";
  return 0;
}
