#include <bits/stdc++.h>
using namespace std;
char s1[200005], s2[200005];
int len;
bool judge(int p, char *s1, char *s2) {
  for (int i = 0; i < p; i++) {
    if (s1[i] != s2[i]) return 0;
  }
  return 1;
}
int check(int p, char *s1, char *s2) {
  if (p == 1) {
    if (s1[0] != s2[0]) return 0;
    return 1;
  }
  if (judge(p, s1, s2)) return 1;
  int len = p;
  if (len & 1) return 0;
  return (check(len / 2, s1, s2) &&
          check(len / 2, s1 + len / 2, s2 + len / 2)) ||
         (check(len / 2, s1 + len / 2, s2) && check(len / 2, s1, s2 + len / 2));
}
int main(void) {
  int i, j;
  while (~scanf("%s%s", s1, s2)) {
    int len = strlen(s1);
    if (check(len, s1, s2))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
