#include <bits/stdc++.h>
using namespace std;
bool func(string s1, string s2) {
  if (s1 == s2) return true;
  if (s1.length() % 2 == 1) return false;
  string a1 = s1.substr(0, s1.length() / 2);
  string a2 = s1.substr(s1.length() / 2);
  string b1 = s2.substr(0, s2.length() / 2);
  string b2 = s2.substr(s1.length() / 2);
  return (((func(a1, b2) && func(a2, b1)) || (func(a1, b1) && func(a2, b2))));
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  bool b = func(s1, s2);
  if (b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
