#include <bits/stdc++.h>
char s1[200010];
char s2[200010];
void lexico(char *s, long int len) {
  long int half, i;
  if (len % 2 == 0) {
    half = len / 2;
    lexico(s, half);
    lexico(s + half, half);
    if (strncmp(s, s + half, half) > 0) {
      for (i = 0; i < half; i++) std::swap(s[i], s[i + half]);
    }
  }
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  long int len1 = strlen(s1);
  long int len2 = strlen(s2);
  lexico(s1, len1);
  lexico(s2, len2);
  if (strcmp(s1, s2) == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
