#include <bits/stdc++.h>
using namespace std;
bool solve(string s1, string s2) {
  if (s1 == s2) return true;
  if (s1.length() != s2.length()) return false;
  if (s1.length() % 2 == 1) return s1 == s2;
  return (solve(s1.substr(0, s1.length() / 2), s2.substr(s2.length() / 2)) &&
          solve(s1.substr(s1.length() / 2), s2.substr(0, s2.length() / 2))) ||
         (solve(s1.substr(0, s1.length() / 2), s2.substr(0, s2.length() / 2)) &&
          solve(s1.substr(s1.length() / 2), s2.substr(s2.length() / 2)));
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (solve(s1, s2))
    printf("YES");
  else
    printf("NO");
}
