#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int inf = 1e7;
const int MAXM = 5e3 + 5;
const int MAXN = 1e6 + 4;
string s1, s2;
int n1, n2;
bool solve(int b1, int e1, int b2, int e2) {
  string x1 = "", x2 = "";
  for (int i = b1; i <= e1; i++) {
    x1 += s1[i - 1];
  }
  for (int i = b2; i <= e2; i++) {
    x2 += s2[i - 1];
  }
  if (x1 == x2) return true;
  if (x1.length() & 1) return (x1 == x2);
  bool ret = false;
  int mid1 = (b1 + e1) / 2;
  int mid2 = (b2 + e2) / 2;
  ret |= (solve(b1, mid1, mid2 + 1, e2) && solve(mid1 + 1, e1, b2, mid2));
  if (ret == true) return ret;
  ret |= (solve(b1, mid1, b2, mid2) && solve(mid1 + 1, e1, mid2 + 1, e2));
  return ret;
}
int main() {
  cin >> s1 >> s2;
  n1 = s1.length();
  n2 = s2.length();
  bool flag = solve(1, n1, 1, n2);
  cout << (flag ? "YES\n" : "NO\n");
  return 0;
}
