#include <bits/stdc++.h>
using namespace std;
string splitit(string a) {
  if (a.size() % 2 == 1) return a;
  string a1 = splitit(a.substr(0, (a.size()) / 2));
  string a2 = splitit(a.substr((a.size()) / 2, (a.size()) / 2));
  if (a1 < a2)
    return a1 + a2;
  else
    return a2 + a1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string a, b;
  cin >> a >> b;
  a = splitit(a);
  b = splitit(b);
  if (a == b)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
