#include <bits/stdc++.h>
using namespace std;
string ms(string s) {
  int l = s.size();
  if (l & 1)
    return s;
  else {
    string a = ms(s.substr(0, l / 2));
    string b = ms(s.substr(l / 2));
    return a < b ? a + b : b + a;
  }
}
int main() {
  string a, b;
  cin >> a >> b;
  cout << (ms(a) == ms(b) ? "YES" : "NO") << '\n';
  return 0;
}
