#include <bits/stdc++.h>
using namespace std;
string str1, str2;
string divide_conquer(string s) {
  if ((s.size() & 1) == 0) {
    string left = divide_conquer(s.substr(0, s.size() >> 1));
    string right = divide_conquer(s.substr(s.size() >> 1));
    if (left < right) return left + right;
    return right + left;
  }
  return s;
}
int main() {
  cin >> str1 >> str2;
  cout << (divide_conquer(str1) == divide_conquer(str2) ? "YES" : "NO");
}
