#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char en = '\n';
const ll llinf = 1LL << 60;
const int inf = 1 << 30;
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
string small(string s) {
  if (s.length() & 1)
    return s;
  else {
    string s1 = small(s.substr(0, s.length() / 2));
    string s2 = small(s.substr(s.length() / 2));
    if (s1 < s2)
      return s1 + s2;
    else
      return s2 + s1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string str1, str2;
  cin >> str1 >> str2;
  if (small(str1) == small(str2))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
