#include <bits/stdc++.h>
using namespace std;
char a[200007], b[200007];
int f(int la, int ra, int lb, int rb) {
  int len = ra - la + 1;
  if (len % 2 == 1) {
    for (int i = 0; i < len; i++)
      if (a[la + i] != b[lb + i]) return 0;
    return 1;
  } else {
    int ma = (la + ra) / 2, mb = (lb + rb) / 2;
    if (f(la, ma, lb, mb) && f(ma + 1, ra, mb + 1, rb)) return 1;
    if (f(la, ma, mb + 1, rb) && f(ma + 1, ra, lb, mb)) return 1;
    return 0;
  }
}
int main() {
  scanf("%s%s", a, b);
  if (f(0, strlen(a) - 1, 0, strlen(b) - 1))
    printf("YES\n");
  else
    printf("NO\n");
}
