#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
string second, t;
string smallest(string second) {
  if ((int)second.size() % 2 == 1) return second;
  int m = (int)second.size() / 2;
  string s1 = smallest(second.substr(0, m));
  string s2 = smallest(second.substr(m, (int)second.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);
  cin >> second >> t;
  if (smallest(second) == smallest(t))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
