#include <bits/stdc++.h>
inline long long Input() {
  long long ret = 0;
  bool isN = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') isN = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return isN ? -ret : ret;
}
inline void Output(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
  putchar('\n');
}
#pragma comment(linker, "/STACK:124000000,124000000")
const long double PI = acos(-1.0);
using namespace std;
char a[220005], b[220005];
bool work(int l1, int r1, int l2, int r2) {
  bool flag = 1;
  int t = r1 - l1;
  for (int i = 0; i <= t; i++) {
    if (a[i + l1] != b[i + l2]) {
      flag = 0;
      break;
    }
  }
  if (flag) return 1;
  t++;
  if (t & 1) return 0;
  int mid1 = (l1 + r1) / 2, mid2 = (l2 + r2) / 2;
  if (work(l1, mid1, mid2 + 1, r2) && work(mid1 + 1, r1, l2, mid2)) return 1;
  if (work(l1, mid1, l2, mid2) && work(mid1 + 1, r1, mid2 + 1, r2)) return 1;
  return 0;
}
int main() {
  scanf("%s%s", a, b);
  int l = strlen(a);
  if (work(0, l - 1, 0, l - 1)) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
