#include <bits/stdc++.h>
using namespace std;
string str1, str2;
int sum[2][30][200005];
bool solve(string &a, string &b, int an, int bn) {
  bool ret = false;
  if (a == b) return true;
  if (a.length() % 2) return false;
  for (int k = 'a'; k <= 'z'; k++) {
    if (sum[0][k - 'a'][an + a.length()] - sum[0][k - 'a'][an] !=
        sum[1][k - 'a'][bn + b.length()] - sum[1][k - 'a'][bn])
      return false;
  }
  string at[2], bt[2];
  bool tt[2][2] = {};
  int as = a.size() / 2, bs = b.size() / 2;
  at[0] = a.substr(0, as);
  at[1] = a.substr(as);
  bt[0] = b.substr(0, bs);
  bt[1] = b.substr(bs);
  if (solve(at[0], bt[0], an, bn) && solve(at[1], bt[1], an + as, bn + bs)) {
    ret = true;
  } else if (solve(at[1], bt[0], an + as, bn) &&
             solve(at[0], bt[1], an, bn + bs)) {
    ret = true;
  }
  return ret;
}
int main() {
  cin >> str1 >> str2;
  for (int i = 0; i < str1.length(); i++) {
    for (int k = 'a'; k <= 'z'; k++) {
      sum[0][k - 'a'][i + 1] = sum[0][k - 'a'][i];
      sum[1][k - 'a'][i + 1] = sum[1][k - 'a'][i];
    }
    sum[0][str1[i] - 'a'][i + 1]++;
    sum[1][str2[i] - 'a'][i + 1]++;
  }
  cout << (solve(str1, str2, 0, 0) ? "YES" : "NO") << endl;
  return 0;
}
