#include <bits/stdc++.h>
using namespace std;
char a[201000], b[201000];
int hash1[201000], hash2[201000], seed = 131, base[201000];
bool solve(int be1, int en1, int be2, int en2) {
  if ((en1 - be1 + 1) & 1 || (en2 - be2 + 1) & 1) return 0;
  int a1, a2, b1, b2;
  int mid1 = (be1 + en1) / 2;
  int mid2 = (be2 + en2) / 2;
  a1 = hash1[mid1];
  if (be1 > 0) a1 -= hash1[be1 - 1] * base[mid1 - be1 + 1];
  a2 = hash1[en1] - hash1[mid1] * base[en1 - mid1];
  b1 = hash2[mid2];
  if (be2 > 0) b1 -= hash2[be2 - 1] * base[mid2 - be2 + 1];
  b2 = hash2[en2] - hash2[mid2] * base[en2 - mid2];
  if ((a1 == b1 || solve(be1, mid1, be2, mid2)) &&
      (a2 == b2 || solve(mid1 + 1, en1, mid2 + 1, en2)))
    return 1;
  else if (((a1 == b2) || solve(be1, mid1, mid2 + 1, en2)) &&
           ((a2 == b1) || solve(mid1 + 1, en1, be2, mid2)))
    return 1;
  return 0;
}
int main() {
  base[1] = seed;
  for (int i = 2; i <= 200000; i++) base[i] = base[i - 1] * seed;
  while (scanf("%s%s", a, b) != EOF) {
    hash1[0] = (a[0] - 'a' + 1);
    int len1 = strlen(a), len2 = strlen(b);
    hash2[0] = (b[0] - 'a' + 1);
    for (int i = 1; i < len1; i++)
      hash1[i] = hash1[i - 1] * seed + (a[i] - 'a' + 1);
    for (int i = 1; i < len2; i++)
      hash2[i] = hash2[i - 1] * seed + (b[i] - 'a' + 1);
    if (hash1[len1 - 1] == hash2[len2 - 1]) {
      puts("YES");
      ;
      continue;
    }
    if (solve(0, len1 - 1, 0, len2 - 1))
      puts("YES");
    else
      puts("NO");
  }
}
