#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int n;
string a;
string b;
bool eq(int La, int Ra, int Lb, int Rb) {
  bool q = 1;
  for (int x = 0; x <= (Ra - La) && q; ++x)
    if (a[La + x] != b[Lb + x]) q = 0;
  if (q)
    return 1;
  else {
    if (Ra - La == Rb - Lb && (Ra - La + 1) % 2 == 0) {
      int mid1 = (La + Ra) / 2;
      int mid2 = (Lb + Rb) / 2;
      return ((eq(La, mid1, Lb, mid2) && eq(mid1 + 1, Ra, mid2 + 1, Rb)) ||
              (eq(La, mid1, mid2 + 1, Rb) && eq(mid1 + 1, Ra, Lb, mid2)));
    } else
      return 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> a;
  cin >> b;
  n = a.size();
  if (eq(0, n - 1, 0, n - 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
