#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
char A[MAXN];
char B[MAXN];
int n;
void open() {
  freopen("B.in", "r", stdin);
  freopen("B.out", "w", stdout);
}
void close() {
  fclose(stdin);
  fclose(stdout);
}
void init() {
  scanf("%s", A + 1);
  scanf("%s", B + 1);
}
bool equal(int l1, int r1, int l2, int r2) {
  int flag = 1;
  for (int i = 0, END = r1 - l1; i <= END; i++)
    if (A[i + l1] != B[i + l2]) {
      flag = 0;
      break;
    }
  if (flag)
    return true;
  else if ((r1 - l1 + 1) & 1)
    return false;
  int mid1 = (l1 + r1) / 2, mid2 = (l2 + r2) / 2;
  if (equal(l1, mid1, l2, mid2)) {
    if (equal(mid1 + 1, r1, mid2 + 1, r2)) return true;
  }
  if (equal(mid1 + 1, r1, l2, mid2)) {
    if (equal(l1, mid1, mid2 + 1, r2)) return true;
  }
}
int main() {
  init();
  int n1 = strlen(A + 1), n2 = strlen(B + 1);
  if (n1 != n2) {
    printf("NO\n");
  } else {
    if (equal(1, n1, 1, n2))
      printf("YES\n");
    else
      printf("NO\n");
  }
  close();
  return 0;
}
