#include <bits/stdc++.h>
using namespace std;
map<pair<string, string>, int> dp;
bool isEq(string a, string b) {
  int r = a.size();
  if (dp.find(make_pair(a, b)) != dp.end())
    return dp[make_pair(a, b)];
  else if (a == b) {
    dp[make_pair(a, b)] = 1;
    return true;
  }
  if (r == 1) {
    dp[make_pair(a, b)] = (a == b);
    return (a == b);
  } else {
    string a1 = a.substr(0, r / 2);
    string a2 = a.substr(r / 2, r / 2);
    string b1 = b.substr(0, r / 2);
    string b2 = b.substr(r / 2, r);
    dp[make_pair(a, b)] =
        (isEq(a1, b1) and isEq(a2, b2) or isEq(a1, b2) and isEq(a2, b1));
    return isEq(a1, b1) and isEq(a2, b2) or isEq(a1, b2) and isEq(a2, b1);
  }
}
int main() {
  string a, b;
  cin >> a;
  cin >> b;
  if (isEq(a, b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
