#include <bits/stdc++.h>
using namespace std;
char a[200005], b[200005];
int len;
bool check(char *s1, char *s2, int len) {
  int i;
  if (len % 2 == 1) {
    for (i = 0; i < len; i++)
      if (s1[i] != s2[i]) return false;
    return true;
  } else {
    return (check(s1, s2, len / 2) &&
            check(s1 + len / 2, s2 + len / 2, len / 2)) ||
           (check(s1, s2 + len / 2, len / 2) &&
            check(s1 + len / 2, s2, len / 2));
  }
}
int main() {
  scanf("%s%s", a, b);
  int len1 = strlen(a);
  int len2 = strlen(b);
  if (len1 != len2) {
    printf("NO\n");
    return 0;
  }
  if (check(a, b, len1))
    printf("YES\n");
  else
    printf("NO\n");
}
