#include <bits/stdc++.h>
using namespace std;
char a[222222], b[222222];
bool cmp(int s1, int e1, int s2, int e2) {
  bool flag = true;
  for (int i = s1, j = s2; i <= e1; i++, j++)
    if (a[i] != b[j]) return false;
  return true;
}
bool solve(int s1, int e1, int s2, int e2) {
  if ((e1 - s1 + 1) % 2) return cmp(s1, e1, s2, e2);
  int mid1 = (s1 + e1) >> 1, mid2 = (s2 + e2) >> 1;
  return solve(s1, mid1, s2, mid2) && solve(mid1 + 1, e1, mid2 + 1, e2) ||
         solve(s1, mid1, mid2 + 1, e2) && solve(mid1 + 1, e1, s2, mid2);
}
int main() {
  scanf("%s%s", a, b);
  int len1 = strlen(a), len2 = strlen(b);
  int flag;
  if (len1 != len2)
    flag = 0;
  else
    flag = solve(0, len1 - 1, 0, len1 - 1);
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
