#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char a[maxn], b[maxn];
int gao(int l, int r, int l1, int r1) {
  int len = r - l + 1, flag = 1;
  for (int i = l; i <= r; i++)
    if (a[i] != b[i - l + l1]) {
      flag = 0;
      break;
    }
  if (flag) return 1;
  if (len & 1) return 0;
  int mid = (l + r) >> 1;
  int mid1 = (l1 + r1) >> 1;
  if (gao(l, mid, l1, mid1) && gao(mid + 1, r, mid1 + 1, r1)) return 1;
  if (gao(l, mid, mid1 + 1, r1) && gao(mid + 1, r, l1, mid1)) return 1;
  return 0;
}
int main() {
  scanf("%s%s", a, b);
  int len = strlen(a);
  if (gao(0, len - 1, 0, len - 1))
    puts("YES\n");
  else
    puts("NO\n");
  return 0;
}
