#include <bits/stdc++.h>
using namespace std;
string dp_func(string str) {
  if (str.size() & 1) return str;
  string gf, my;
  for (int i = 0; i < str.size() / 2; i++) my += str[i];
  for (int i = str.size() / 2; str[i]; i++) gf += str[i];
  string pts = dp_func(gf);
  string rts = dp_func(my);
  if (pts > rts) swap(pts, rts);
  return pts + rts;
}
int main() {
  string str, str2;
  cin >> str >> str2;
  str = dp_func(str);
  str2 = dp_func(str2);
  if (str == str2)
    printf("YES\n");
  else
    cout << "NO\n";
}
