#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793238462;
string numkey = "0123456789";
string uni = "abcdefghijklmnopqrstuvwxyz";
long long int dx[4] = {0, 0, 1, -1};
long long int dy[4] = {1, -1, 0, 0};
long long int INF = (1LL << 62);
string smallest(string s) {
  if (s.length() % 2 == 1) return s;
  string s1 = smallest(s.substr(0, s.length() / 2));
  string s2 = smallest(s.substr(s.length() / 2, s.length() / 2));
  if (s1 < s2) return s2 + s1;
  return s1 + s2;
}
signed main() {
  string a, b;
  cin >> a >> b;
  string q = smallest(a);
  string p = smallest(b);
  if (p == q) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
