#include <bits/stdc++.h>
using namespace std;
string solve(string s) {
  if (s.size() % 2 == 1) return s;
  string s1 = solve(s.substr(0, s.size() / 2));
  string s2 = solve(s.substr(s.size() / 2, s.size()));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  if (solve(s1) == solve(s2))
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
