#include <bits/stdc++.h>
using namespace std;
string reduce(string s) {
  if (s.size() % 2)
    return s;
  else {
    string a = reduce(s.substr(0, s.size() / 2)),
           b = reduce(s.substr(s.size() / 2));
    return (a > b ? b + a : a + b);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a, b;
  cin >> a >> b;
  cout << (reduce(a) == reduce(b) ? "YES" : "NO");
  return 0;
}
