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