#include <bits/stdc++.h>
using namespace std;
string convert(string s) {
  int l = s.size();
  if (l % 2 == 1) return s;
  string s1 = s.substr(0, l / 2), s2 = s.substr(l / 2);
  s1 = convert(s1);
  s2 = convert(s2);
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
bool equivalent(string s1, string s2) {
  s1 = convert(s1);
  s2 = convert(s2);
  return s1 == s2;
}
int main() {
  string a, b;
  cin >> a >> b;
  if (equivalent(a, b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
