#include <bits/stdc++.h>
using namespace std;
string s1, s2;
bool rec(int st1, int a, int st2, int b) {
  if (a % 2) {
    for (int i = 0; i < a; i++) {
      if (s1[st1 + i] != s2[st2 + i]) return false;
    }
    return true;
  }
  int mid1 = a / 2, mid2 = b / 2;
  if ((rec(st1, mid1, st2, mid2) && rec(st1 + mid1, mid1, st2 + mid2, mid2)) ||
      (rec(st1, mid1, st2 + mid2, mid2) && rec(st1 + mid1, mid1, st2, mid2)))
    return true;
  else
    return false;
}
int main() {
  cin >> s1 >> s2;
  if (rec(0, s1.length(), 0, s2.length()))
    cout << "YES";
  else
    cout << "NO";
}
