#include <bits/stdc++.h>
using namespace std;
const long long N = 300010, M = 1000010;
long long n, res, h[3][N], sz;
string fun(string s) {
  long long sz = s.length();
  if (sz % 2) return s;
  string s1 = fun(s.substr(0, sz / 2));
  string s2 = fun(s.substr(sz / 2, sz));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int solve() {
  string s;
  cin >> s;
  string t1 = fun(s);
  cin >> s;
  string t2 = fun(s);
  if (t1 == t2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
int main() { return solve(); }
