#include <bits/stdc++.h>
using namespace std;
bool equal(char a[], char b[], int len) {
  if (len % 2) {
    for (int i = 0; i < len; i++) {
      if (a[i] != b[i]) return false;
    }
    return true;
  }
  int le = len / 2;
  char *pa = &a[le], *pb = &b[le];
  return (equal(a, b, le) && equal(pa, pb, le)) ||
         (equal(a, pb, le) && equal(pa, b, le));
}
int main() {
  char a[200000 + 9], b[200000 + 9];
  scanf("%s%s", a, b);
  int l = strlen(a);
  if (equal(a, b, l))
    printf("YES");
  else
    printf("NO");
}
