#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
const long long INFll = 1ll * INF * INF;
const int MOD = 1000000007;
const int N = 200005;
int st1[N];
int st2[N];
int h1[N];
int h2[N];
int h3[N];
int h4[N];
string a, b;
int n;
inline bool equ(int i1, int j1, int i2, int j2) {
  for (int i = i1; i <= j1; ++i)
    if (a[i] != b[i2 + i - i1]) return 0;
  return 1;
}
bool go(int i1, int j1, int i2, int j2) {
  if (equ(i1, j1, i2, j2)) return 1;
  if ((j1 - i1 + 1) % 2) return 0;
  int mid1 = (i1 + j1) / 2;
  int mid2 = (i2 + j2) / 2;
  return ((go(i1, mid1, mid2 + 1, j2) && go(mid1 + 1, j1, i2, mid2) ||
           go(i1, mid1, i2, mid2) && go(mid1 + 1, j1, mid2 + 1, j2)));
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  n = a.size();
  if (go(0, n - 1, 0, n - 1))
    cout << "YES";
  else
    cout << "NO";
  ;
  return 0;
}
