#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
string s, t;
string convert(string a) {
  int n = a.length();
  if (n % 2) return a;
  string b = a.substr(0, n / 2), c = a.substr(n / 2, n / 2);
  b = convert(b);
  c = convert(c);
  if (b < c)
    return b + c;
  else
    return c + b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s >> t;
  s = convert(s);
  t = convert(t);
  cout << ((s == t) ? "YES" : "NO") << "\n";
  return 0;
}
