#include <bits/stdc++.h>
using namespace std;
string smallestEq(string s) {
  int stringLength = s.length();
  if (stringLength % 2 == 1) return s;
  string s1, s2;
  s1 = smallestEq(s.substr(0, stringLength / 2));
  s2 = smallestEq(s.substr(stringLength / 2, stringLength / 2));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  s1 = smallestEq(s1);
  s2 = smallestEq(s2);
  if (s1 == s2) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}
