#include <bits/stdc++.h>
char str1[222222];
char str2[222222];
int len1, len2;
void input() {
  scanf("%s %s", str1, str2);
  len1 = strlen(str1);
  len2 = strlen(str2);
  return;
}
bool isSame(int s1, int g1, int s2, int g2) {
  bool checkAllSame = true;
  for (int i = s1; i <= g1; i++) {
    if (str1[i] != str2[i - s1 + s2]) {
      checkAllSame = false;
      break;
    }
  }
  if (checkAllSame) return true;
  if ((g1 - s1) % 2 == 0) return false;
  int m1 = (s1 + g1) / 2;
  int m2 = (s2 + g2) / 2;
  if ((isSame(s1, m1, s2, m2) && isSame(m1 + 1, g1, m2 + 1, g2)) ||
      (isSame(s1, m1, m2 + 1, g2) && isSame(m1 + 1, g1, s2, m2)))
    return true;
  return false;
}
int main() {
  input();
  if (isSame(0, len1 - 1, 0, len2 - 1))
    puts("YES");
  else
    puts("NO");
  return 0;
}
