#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
string n, m;
bool chk(string x = n, string y = m) {
  if (x == y) return 1;
  if (x.size() != y.size() || (x.size() & 1)) return 0;
  string a = x.substr(x.size() / 2), c = x.substr(0, x.size() / 2);
  string b = y.substr(x.size() / 2), d = y.substr(0, x.size() / 2);
  return (chk(a, d) && chk(b, c)) || (chk(a, b) && chk(c, d));
}
int main() {
  cin >> n >> m;
  puts(chk() ? "YES" : "NO");
  return 0;
}
