#include <bits/stdc++.h>
using namespace std;
bool dfs(char* a, char* b, int l) {
  if (strncmp(a, b, l) == 0) return true;
  if (l % 2 != 0) return false;
  int n = l / 2;
  if (dfs(a, b + n, n) && dfs(a + n, b, n)) return true;
  if (dfs(a, b, n) && dfs(a + n, b + n, n)) return true;
  return false;
}
int main() {
  char a[200005], b[200005];
  while (cin >> a >> b) {
    int len = strlen(a);
    if (dfs(a, b, len))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
