#include <bits/stdc++.h>
char word1[222222];
char word2[222222];
long long int isEqual(long long int s1, long long int s2,
                      long long int wordLenght) {
  for (int i = 0; i < wordLenght; i++) {
    if (word1[s1 + i] != word2[s2 + i]) {
      return 0;
    }
  }
  return 1;
}
long long int isEquivalentString(long long int s1, long long int f1,
                                 long long int s2, long long int f2) {
  long long int wordLenght = f1 - s1 + 1;
  if ((wordLenght / 2) * 2 != wordLenght) {
    return isEqual(s1, s2, wordLenght);
  } else {
    long long int half = wordLenght / 2;
    if (isEquivalentString(s1, f1 - half, s2 + half, f2) &&
        isEquivalentString(s1 + half, f1, s2, f2 - half)) {
      return 1;
    } else if ((isEquivalentString(s1, f1 - half, s2, f2 - half) &&
                isEquivalentString(s1 + half, f1, s2 + half, f2))) {
      return 1;
    } else
      return 0;
  }
}
int main(int argc, const char* argv[]) {
  long long int lenght = 0;
  scanf("%s", word1);
  scanf("%s", word2);
  lenght = (int)strlen(word1);
  if (isEquivalentString(0, lenght - 1, 0, lenght - 1))
    printf("YES");
  else
    printf("NO");
  return 0;
}
