#include <bits/stdc++.h>
using namespace std;
char a[200010], b[200010], res[400020];
int l1, l2;
bool equal(int p, int q, int r, int s) {
  for (int i = 0; i <= (q - p); i++)
    if (res[p + i] != res[r + i]) return false;
  return true;
}
bool check(int p, int q, int r, int s) {
  int x = q - p + 1;
  int y = s - r + 1;
  if (x != y) return false;
  if (p > q || r > s) return false;
  if (equal(p, q, r, s)) return true;
  if (x % 2 != 0) return false;
  int m1 = (p + q - 1) / 2;
  int m2 = (r + s - 1) / 2;
  return (check(p, m1, r, m2) && check(m1 + 1, q, m2 + 1, s)) ||
         (check(p, m1, m2 + 1, s) && check(m1 + 1, q, r, m2));
}
int main() {
  scanf("%s\n", a);
  scanf("%s\n", b);
  for (l1 = 0; a[l1] != '\0'; l1++) res[l1] = a[l1];
  for (l2 = 0; b[l2] != '\0'; l2++) res[l1 + l2] = b[l2];
  res[l1 + l2] = '\0';
  if (check(0, l1 - 1, l1, l1 + l2 - 1)) {
    puts("YES");
  } else
    puts("NO");
}
