#include <bits/stdc++.h>
using namespace std;
string s1, s2;
bool isEq(int start1, int len1, int start2, int len2) {
  if (len1 & 1) {
    for (int i = 0; i < len1; i++) {
      if (s1[start1 + i] != s2[start2 + i]) return false;
    }
    return true;
  }
  int mid1 = len1 / 2, mid2 = len2 / 2;
  int skip1 = len1 % 2, skip2 = len2 % 2;
  bool result = ((isEq(start1, mid1, start2, mid2) &&
                  isEq(start1 + mid1, mid1, start2 + mid2, mid2)) ||
                 (isEq(start1, mid1, start2 + mid2, mid2) &&
                  isEq(start1 + mid1, mid1, start2, mid2)));
  return result;
}
int main() {
  cin >> s1 >> s2;
  if (s1.compare(s2) == 0)
    printf("YES\n");
  else {
    if (isEq(0, s1.length(), 0, s2.length()))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
