#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
using namespace std;
char s[200010], t[200010];
int flag;
bool cmp(char x[], char y[], int len) {
  int ok = 1;
  for (int i = 0; i < len; i++) {
    if (x[i] != y[i]) {
      ok = 0;
    }
  }
  return ok;
}
int dfs(char x[], char y[], int len) {
  if (cmp(x, y, len)) return 1;
  if (len % 2 == 0) {
    if ((dfs(x, y, len / 2) && dfs(x + len / 2, y + len / 2, len / 2)) ||
        (dfs(x, y + len / 2, len / 2) && dfs(x + len / 2, y, len / 2)))
      return 1;
  }
  return 0;
}
int main() {
  while (gets(s)) {
    gets(t);
    int ls = strlen(s);
    if (dfs(s, t, ls))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
