#include <bits/stdc++.h>
using namespace std;
bool equi(string s1, string s2) {
  if (s1 == s2) return true;
  int l = s1.length();
  if (l % 2 || l % 2) return false;
  if (l <= 0) return false;
  if (equi(s1.substr(0, l >> 1), s2.substr(l >> 1, l)) &&
      equi(s1.substr(l >> 1, l), s2.substr(0, l >> 1)))
    return true;
  if (equi(s1.substr(0, l >> 1), s2.substr(0, l >> 1)) &&
      equi(s1.substr(l >> 1, l), s2.substr(l >> 1, l)))
    return true;
  return false;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.length() != s2.length())
    printf("NO");
  else {
    if (s1 == s2) {
      printf("YES");
    } else {
      if (equi(s1, s2))
        printf("YES");
      else
        printf("NO");
    }
  }
  return 0;
}
