#include <bits/stdc++.h>
using namespace std;
const int N = 2001000;
string sa, sb;
int pd(int l, int r, int ll, int rr) {
  for (int i = l; i <= r; i++)
    if (sa[i - 1] != sb[i - l + ll - 1]) return 0;
  return 1;
}
int solve(int l, int r, int ll, int rr) {
  if ((r - l) % 2 == 0) return pd(l, r, ll, rr);
  int mid = (l + r) >> 1, midx = (ll + rr) >> 1;
  if (solve(l, mid, ll, midx) && solve(mid + 1, r, midx + 1, rr)) return 1;
  if (solve(l, mid, midx + 1, rr) && solve(mid + 1, r, ll, midx)) return 1;
  return 0;
}
int main() {
  cin >> sa >> sb;
  int len = sa.length();
  if (solve(1, len, 1, len))
    puts("YES");
  else
    puts("NO");
}
