#include <bits/stdc++.h>
using namespace std;
std::map<string, bool> myMap;
bool equal(string a, string b) {
  std::map<string, bool>::iterator it;
  it = myMap.find(a + b);
  if (it != myMap.end()) {
    return it->second;
  }
  if (a.compare(b) == 0) {
    myMap.insert(std::make_pair(a + b, true));
    myMap.insert(std::make_pair(b + a, true));
    return true;
  } else if (a.size() % 2 == 1) {
    myMap.insert(std::make_pair(a + b, false));
    myMap.insert(std::make_pair(b + a, false));
    return false;
  }
  string c = a.substr(0, a.size() / 2);
  string d = b.substr(0, b.size() / 2);
  string e = a.substr(a.size() / 2, a.size() / 2);
  string f = b.substr(b.size() / 2, b.size() / 2);
  return (equal(c, f) && equal(e, d) || equal(c, d) && equal(e, f));
}
int main() {
  string a, b;
  cin >> a >> b;
  if (equal(a, b))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
