#include <bits/stdc++.h>
using namespace std;
string f(string a) {
  int len = a.size();
  if (len & 1) return a;
  int mid = len >> 1;
  string x = f(a.substr(0, mid));
  string y = f(a.substr(mid, mid));
  if (x < y)
    return x + y;
  else
    return y + x;
}
int main() {
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  if (f(s) == f(t))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
