#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
string a[2];
int n;
int len(int l, int r) { return r - l + 1; }
string minstr(int l, int r, int i) {
  if (l == r) {
    return a[i].substr(l, 1);
  }
  int mid = (l + r) >> 1;
  if (len(l, mid) != len(mid + 1, r)) return a[i].substr(l, r - l + 1);
  string t1 = minstr(l, mid, i);
  string t2 = minstr(mid + 1, r, i);
  if (t2 + t1 < t1 + t2) return t2 + t1;
  return t1 + t2;
}
int main() {
  cin >> a[0] >> a[1];
  n = a[0].size();
  a[0] = ' ' + a[0];
  a[1] = ' ' + a[1];
  string t1 = minstr(1, n, 0);
  string t2 = minstr(1, n, 1);
  if (t1 == t2)
    cout << "YES";
  else
    cout << "NO";
}
