#include <bits/stdc++.h>
using namespace std;
bool solve(string a, string b) {
  if (a.size() % 2 == 1)
    return a == b;
  else {
    int n = a.size();
    string a1 = a.substr(0, n / 2);
    string a2 = a.substr(n / 2, n / 2);
    string b1 = b.substr(0, n / 2);
    string b2 = b.substr(n / 2, n / 2);
    return ((solve(a1, b2) and solve(a2, b1)) or
            (solve(a1, b1) and solve(a2, b2)));
  }
}
int main() {
  char a[200005], b[200005];
  scanf("%s", a);
  scanf("%s", b);
  int x = solve(a, b);
  if (x == 1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
