#include <bits/stdc++.h>
using namespace std;
class Solution {
  string a, b;
  void condense(int l, int r, string &s) {
    if (r - l & 1) return;
    int m = l + r >> 1;
    int n = r - l >> 1;
    condense(l, m, s), condense(m, r, s);
    if (s.substr(l, n) > s.substr(m, n)) {
      for (int i = l; i < m; ++i) {
        swap(s[i], s[i + n]);
      }
    }
  }

 public:
  void run() {
    cin >> a >> b;
    int n = a.size();
    condense(0, n, a), condense(0, n, b);
    cout << (a == b ? "YES\n" : "NO\n");
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Solution().run();
}
