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