#include <bits/stdc++.h>
using namespace std;
string s1, s2;
bool equiv(int i1, int i2, int l) {
  if (l % 2) {
    for (int i = 0; i < l; i++)
      if (s1[i1 + i] != s2[i2 + i]) return 0;
    return 1;
  }
  if (equiv(i1, i2, l / 2)) return equiv(i1 + l / 2, i2 + l / 2, l / 2);
  return (equiv(i1, i2 + l / 2, l / 2) && equiv(i1 + l / 2, i2, l / 2));
}
int main() {
  cin >> s1 >> s2;
  if (s1.length() != s2.length())
    puts("NO");
  else if (equiv(0, 0, s1.length()))
    puts("YES");
  else
    puts("No");
  return 0;
}
