#include <bits/stdc++.h>
using namespace std;
string solve(string s) {
  if (s.length() & 1) return s;
  string s1 = solve(s.substr(0, s.length() / 2));
  string s2 = solve(s.substr(s.length() / 2, s.length()));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  string a, b;
  cin >> a >> b;
  int n = a.length();
  string ans1 = solve(a);
  string ans2 = solve(b);
  if (ans1 == ans2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
