#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
string findsmallest(string s) {
  if (s.length() & 1) return s;
  string s1 = findsmallest(s.substr(0, s.length() / 2)),
         s2 = findsmallest(s.substr(s.length() / 2, s.length()));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  string s[2];
  cin >> s[0] >> s[1];
  s[0] = findsmallest(s[0]);
  s[1] = findsmallest(s[1]);
  if (s[0] == s[1])
    printf("YES\n");
  else
    printf("NO\n");
}
