#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
char a[maxn], b[maxn];
int n;
bool dfs(int al, int ar, int bl, int br) {
  int len = ar - al + 1;
  int ma = (al + ar - 1) / 2;
  int mb = (bl + br - 1) / 2;
  if (len % 2 == 1) {
    for (int i = 0; i < len; i++) {
      if (a[al + i] != b[bl + i]) return false;
    }
    return true;
  } else {
    return (dfs(al, ma, bl, mb) && dfs(ma + 1, ar, mb + 1, br)) ||
           (dfs(al, ma, mb + 1, br) && dfs(ma + 1, ar, bl, mb));
  }
}
int main() {
  int al, bl;
  scanf("%s%s", a + 1, b + 1);
  al = strlen(a + 1);
  bl = strlen(b + 1);
  n = strlen(a + 1);
  if (al != bl) {
    printf("NO\n");
  } else {
    if (dfs(1, n, 1, n)) {
      printf("YES\n");
    } else
      printf("NO\n");
  }
  return 0;
}
