#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100005];
long long dem = 0;
bool solve(string a, string b) {
  if (a == b) {
    return 1;
  }
  string a1 = a, b1 = b;
  long long n = a.size();
  if (n % 2 == 0) {
    a1.erase(0, n / 2);
    b1.erase(0, n / 2);
    a.erase(n / 2, n);
    b.erase(n / 2, n);
    if ((solve(a, b1) && solve(a1, b)) || (solve(a, b) && solve(a1, b1))) {
      return 1;
    }
  }
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  if (solve(a, b)) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
