#include <bits/stdc++.h>
using namespace std;
long long int n, s, m, k, ans, b, d, f, s1, s2, s3, r, w, a, c, z2, z1, z3,
    ans1, p;
string j, t, g;
bool ww = false, wwr = false;
set<int> ss;
vector<pair<long long int, pair<long long int, long long int>>> o;
long long int x1[2010], x2[2010], x3[100], x4[100];
string estr(string ah) {
  if (ah.length() % 2 == 1) return ah;
  string ah1 = estr(ah.substr(ah.length() / 2, ah.length()));
  string ah2 = estr(ah.substr(0, ah.length() / 2));
  if (ah1 > ah2) swap(ah1, ah2);
  string ahh = ah1 + ah2;
  return ahh;
}
int main() {
  cin >> j;
  cin >> t;
  n = j.length();
  if (estr(j) != estr(t)) {
    cout << "NO";
  } else
    cout << "YES";
  return 0;
}
