#include <bits/stdc++.h>
using namespace std;
bool flag;
string s1, s2;
bool newnew(string s1, string s2) {
  int len = s1.size();
  if (s1 == s2)
    return true;
  else if (len % 2 != 0)
    return false;
  else {
    if (len == 1) return false;
    string s3 = s1.substr(0, len / 2);
    string s4 = s1.substr(len / 2, len / 2);
    string s5 = s2.substr(0, len / 2);
    string s6 = s2.substr(len / 2, len / 2);
    if (newnew(s3, s6) && newnew(s4, s5)) return true;
    if (newnew(s3, s5) && newnew(s4, s6)) return true;
  }
  return false;
}
int main() {
  cin >> s1;
  cin >> s2;
  flag = newnew(s1, s2);
  if (!flag)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
