#include <bits/stdc++.h>
using namespace std;
bool equal(string &s1, string &s2) {
  int len = s1.size();
  if (s1 == s2) return true;
  if (len & 1) return false;
  string p1s1, p2s1, p1s2, p2s2;
  p1s1 = s1.substr(0, len / 2);
  p2s1 = s1.substr(len / 2, len / 2);
  p1s2 = s2.substr(0, len / 2);
  p2s2 = s2.substr(len / 2, len / 2);
  if ((equal(p1s1, p1s2) && equal(p2s1, p2s2)) ||
      (equal(p2s1, p1s2) && equal(p1s1, p2s2)))
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  string s1, s2;
  cin >> s1 >> s2;
  if (equal(s1, s2))
    cout << "YES";
  else
    cout << "NO";
}
