#include <bits/stdc++.h>
using namespace std;
string smallest(string S) {
  if (S.length() % 2 == 1) return S;
  string s1 = smallest(S.substr(0, S.length() / 2));
  string s2 = smallest(S.substr(S.length() / 2, S.length()));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  string a, b, A, B;
  cin >> a >> b;
  A = smallest(a);
  B = smallest(b);
  if (A == B)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
