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