#include <bits/stdc++.h>
std::string a, b;
std::string cal(std::string a) {
  if (a.length() % 2) return a;
  std::string s1 = cal(a.substr(0, a.length() / 2));
  std::string s2 = cal(a.substr(a.length() / 2, a.length()));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  std::cin >> a >> b;
  a = cal(a);
  b = cal(b);
  if (a == b)
    puts("YES");
  else
    puts("NO");
  return 0;
}
