#include <bits/stdc++.h>
using namespace std;
char s[200001], t[200001];
bool equal(int low_s, int high_s, int low_t, int high_t) {
  int flag = low_t, j;
  for (int i = low_s, j = low_t; i <= high_s; i++, j++) {
    if (s[i] != t[j]) return false;
  }
  return true;
}
bool f(int low_s, int high_s, int low_t, int high_t) {
  if ((high_s - low_s + 1) % 2 == 1) {
    return equal(low_s, high_s, low_t, high_t);
  }
  if (equal(low_s, high_s, low_t, high_t)) return true;
  int mid_s = (low_s + high_s) / 2;
  int mid_t = (low_t + high_t) / 2;
  return (f(low_s, mid_s, low_t, mid_t) &&
          f(mid_s + 1, high_s, mid_t + 1, high_t)) ||
         (f(low_s, mid_s, mid_t + 1, high_t) &&
          f(mid_s + 1, high_s, low_t, mid_t));
}
int main() {
  scanf("%s %s", s, t);
  int len = strlen(s) - 1;
  if (f(0, len, 0, len)) {
    printf("YES");
  } else
    printf("NO");
  return 0;
}
