#include <bits/stdc++.h>
using namespace std;
string a, b;
int n;
string smallstr(string s) {
  int n = s.size();
  if (n % 2) return s;
  string s1 = smallstr(s.substr(0, n / 2));
  string s2 = smallstr(s.substr(n / 2));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  cin >> a >> b;
  if (smallstr(a) == smallstr(b))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
