#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 10000005;
using namespace std;
string a, b;
string smallest(string second) {
  if (second.length() % 2 == 1) return second;
  string s1 = smallest(second.substr(0, second.length() / 2));
  string s2 = smallest(second.substr(second.length() / 2, second.length() / 2));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  cin >> a >> b;
  if (smallest(a) == smallest(b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
