#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 1000;
char s1[maxn];
char s2[maxn];
int judge(int st1, int en1, int st2, int en2) {
  int sign = 0;
  for (int i = st1, j = st2; i <= en1; i++, j++) {
    if (s1[i] != s2[j]) {
      sign = 1;
      break;
    }
  }
  if (sign == 0)
    return 1;
  else {
    if ((en1 - st1 + 1) % 2 == 0) {
      int mid1 = st1 + (en1 - st1 + 1) / 2 - 1;
      int mid2 = st2 + (en2 - st2 + 1) / 2 - 1;
      if (judge(st1, mid1, st2, mid2) && judge(mid1 + 1, en1, mid2 + 1, en2))
        return 1;
      if (judge(st1, mid1, mid2 + 1, en2) && judge(mid1 + 1, en1, st2, mid2))
        return 1;
    }
  }
  return 0;
}
int main() {
  int len1, len2;
  scanf("%s%s", s1, s2);
  len1 = strlen(s1);
  len2 = strlen(s2);
  if (len1 != len2)
    cout << "NO\n" << endl;
  else {
    int sign;
    sign = judge(0, len1 - 1, 0, len1 - 1);
    if (sign)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
