#include <bits/stdc++.h>
using namespace std;
string s1, s2;
bool f(string a, string b) {
  if (a == b) return true;
  int len1 = a.size(), len2 = b.size();
  if (len1 & 1 || len2 & 1) return false;
  string ta1 = a.substr(0, len1 / 2), ta2 = a.substr(len1 / 2, len1 / 2);
  string tb1 = b.substr(0, len2 / 2), tb2 = b.substr(len2 / 2, len2 / 2);
  if ((f(ta1, tb2) && f(ta2, tb1)) || (f(ta1, tb1) && f(ta2, tb2))) return true;
  return false;
}
int main() {
  cin >> s1;
  cin >> s2;
  if (f(s1, s2))
    puts("YES");
  else
    puts("NO");
  return 0;
}
