#include <bits/stdc++.h>
char x[200001], y[200001];
int l;
using namespace std;
bool isequal(int s1, int e1, int s2, int e2) {
  if (!((e1 - s1) & 1)) {
    for (int f = s1 - 1, s = s2 - 1; f <= e1 - 1; f++, s++) {
      if (x[f] != y[s]) return false;
    }
    return true;
  }
  int L = e1 - s1 + 1;
  int m1 = (s1 + e1) / 2;
  int m2 = (s2 + e2) / 2;
  return ((isequal(s1, m1, s2, m2) and isequal(m1 + 1, e1, m2 + 1, e2)) or
          (isequal(s1, m1, m2 + 1, e2) and isequal(m1 + 1, e1, s2, m2)));
}
int main() {
  scanf("%s", x);
  scanf("%s", y);
  l = strlen(x);
  int l2 = strlen(y);
  if (l == l2) {
    if (isequal(1, l, 1, l))
      printf("YES\n");
    else
      printf("NO\n");
  } else
    printf("NO\n");
  return 0;
}
