#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
inline const int getint() {
  int r = 0, k = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') k = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) r = r * 10 + c - '0';
  return k * r;
}
const int maxn = 2e5 + 10;
const int maxm = 5e4 * 4 + 10;
const int inf = 1e9;
int a[10];
char s1[maxn], s2[maxn];
int n, m;
bool check(int len, int la, int lb) {
  if (len & 1) {
    int i;
    for (i = 0; i <= len - 1; i++)
      if (s1[la + i] != s2[lb + i]) {
        return false;
      }
    return true;
  } else {
    int flag = 1;
    int i;
    for (i = 0; i <= len - 1; i++)
      if (s1[la + i] != s2[lb + i]) {
        flag = 0;
        break;
      }
    if (flag) return true;
    if ((check(len / 2, la, lb) &&
         check(len / 2, la + len / 2, lb + len / 2)) ||
        (check(len / 2, la, lb + len / 2) &&
         check(len / 2, la + len / 2, lb))) {
      return true;
    } else
      return false;
  }
}
int main() {
  while (scanf("%s%s", s1, s2) != EOF) {
    int len1 = strlen(s1);
    if (check(len1, 0, 0)) {
      puts("YES");
    } else
      puts("NO");
  }
  return 0;
}
