#include <bits/stdc++.h>
using namespace std;
string s1, s2;
bool eq(int a1, int b1, int a2, int b2) {
  if ((b1 - a1) & 1) {
    while (a1 < b1) {
      if (s1[a1] != s2[a2]) return 0;
      ++a1;
      ++a2;
    }
    return 1;
  }
  int m1 = (a1 + b1) / 2;
  int m2 = (a2 + b2) / 2;
  return (eq(a1, m1, a2, m2) && eq(m1, b1, m2, b2)) ||
         (eq(a1, m1, m2, b2) && eq(m1, b1, a2, m2));
}
bool func() {
  if (s1.length() != s2.length()) return 0;
  if (eq(0, s1.length(), 0, s2.length())) {
    return 1;
  }
}
int main() {
  cin >> s1 >> s2;
  if (func())
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
