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