#include <bits/stdc++.h>
using namespace std;
int len;
int hashL[200010], hashS[200010];
string A, B;
pair<long long, long long> getHash(pair<long long, long long> X,
                                   pair<long long, long long> Y, int ind) {
  if (X > Y) {
    swap(X, Y);
  }
  return make_pair((X.first * hashL[ind] + Y.first) % 1000000009,
                   (X.second * hashS[ind] + Y.second) % 666013);
}
pair<long long, long long> calc(int beg, int fin, string &s) {
  pair<long long, long long> ans;
  if ((fin - beg + 1) % 2) {
    ans = make_pair(0, 0);
    for (int i = beg; i <= fin; i++) {
      ans.first = (ans.first * 26 + (s[i] - 'a')) % 1000000009;
      ans.second = (ans.second * 26 + (s[i] - 'a')) % 666013;
    }
    return ans;
  }
  int mid = (beg + fin) / 2;
  ans = getHash(calc(beg, mid, s), calc(mid + 1, fin, s), mid - beg + 1);
  return ans;
}
int main() {
  cin >> A >> B;
  A = "#" + A;
  B = "#" + B;
  len = A.size();
  hashL[0] = hashS[0] = 1;
  for (int i = 1; i < len; i++) {
    hashL[i] = (hashL[i - 1] * 26) % 1000000009;
    hashS[i] = (hashS[i - 1] * 26) % 666013;
  }
  if (calc(1, len - 1, A) == calc(1, len - 1, B)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
