#include <bits/stdc++.h>
using namespace std;
string s, t;
bool chk(int a1, int a2, int b1, int b2) {
  bool b3 = 0, b4 = 0;
  if (a1 == a2 && b1 == b2) return s[a1] == t[b1];
  if ((a2 - a1 + 1) & 1) b3 = 1;
  if ((b2 - b2 + 1) & 1) b4 = 1;
  if (!(b3 && b4)) {
    bool r = 1;
    for (int x = a1, y = b1; x < a2 && y < b2; x++, y++)
      if (s[x] != t[y]) r = 0;
    return r;
  } else {
    int midA = (a1 + a2) / 2;
    int midB = (b1 + b2) / 2;
    return (chk(a1, midA, b1, midB) && chk(midA, a2, midB, b2)) ||
           (chk(midA, a2, b1, midB) && chk(a1, midA, midB, b2));
  }
}
int main() {
  cin >> s >> t;
  cout << (chk(0, s.length(), 0, t.length()) ? "YES" : "NO");
}
