#include <bits/stdc++.h>
using namespace std;
char s1[205000], s2[205000];
int n;
inline bool fen(int l1, int r1, int l2, int r2) {
  bool boo = false;
  int x = r2 - l2;
  for (int i = 0; i <= x; ++i)
    if (s1[l1 + i] != s2[l2 + i]) {
      boo = true;
      break;
    }
  if (!boo) return true;
  boo = false;
  if (((r1 - l1 + 1) % 2) != 0) return false;
  if (l1 >= r1) return false;
  int mid1 = (r1 + l1 - 1) / 2, mid2 = (r2 + l2 - 1) / 2;
  x = mid1 - l1;
  for (int i = 0; i <= x; ++i)
    if (s1[l1 + i] != s2[mid2 + i + 1] || s2[l2 + i] != s1[mid1 + i + 1]) {
      boo = true;
      break;
    }
  if (!boo) return true;
  if (fen(l1, mid1, l2, mid2) && fen(mid1 + 1, r1, mid2 + 1, r2)) return true;
  if (fen(l1, mid1, mid2 + 1, r2) && fen(mid1 + 1, r1, l2, mid2)) return true;
  return false;
}
int main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  n = strlen(s1 + 1);
  if (fen(1, n, 1, n))
    printf("YES\n");
  else
    printf("NO\n");
}
