#include <bits/stdc++.h>
using namespace std;
bool solve(string a, string b) {
  if (a.length() & 1)
    return a == b;
  else {
    string a_f = a.substr(0, a.length() / 2);
    string a_l = a.substr(a.length() / 2, a.length() / 2);
    string b_f = b.substr(0, b.length() / 2);
    string b_l = b.substr(b.length() / 2, b.length() / 2);
    return solve(a_f, b_l) && solve(a_l, b_f) ||
           solve(a_f, b_f) && solve(a_l, b_l);
  }
}
int main() {
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1 >> s2;
  if (solve(s1, s2))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
