#include <bits/stdc++.h>
using namespace std;
bool f(string s1, string s2) {
  if (s1 == s2) return true;
  bool ans = false;
  string t1(s1.begin(), s1.begin() + s1.size() / 2);
  string t2(s1.begin() + s1.size() / 2, s1.end());
  string t3(s2.begin(), s2.begin() + s2.size() / 2);
  string t4(s2.begin() + s2.size() / 2, s2.end());
  if (s1.size() % 2 == 0 && s2.size() % 2 == 0) {
    ans = ans | (f(t1, t3) && f(t2, t4));
  }
  if (!ans)
    if (s1.size() % 2 == 0 && s2.size() % 2 == 0) {
      ans = ans | (f(t1, t4) && f(t2, t3));
    }
  return ans;
}
string cf(string s) {
  if (s.size() & 1) return s;
  string s1 = cf(s.substr(0, s.size() / 2));
  string s2 = cf(s.substr(s.size() / 2, s.size()));
  if (s1 < s2)
    return s1 + s2;
  else
    return s2 + s1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  if (cf(s1) == cf(s2))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
