#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long base = 39;
const long long MOD = 1e9 + 9;
long long power[N];
long long hash1[N];
long long hash2[N];
string a, b;
bool cmp(int idx1, int idx2, int siz) {
  if (siz == 1) {
    return (a[idx1] == b[idx2]);
  }
  long long val1 = (hash1[idx1 + siz] - hash1[idx1] + MOD) % MOD;
  val1 *= power[a.size() - idx1];
  val1 = val1 % MOD;
  long long val2 = (hash2[idx2 + siz] - hash2[idx2] + MOD) % MOD;
  val2 *= power[a.size() - idx2];
  val2 = val2 % MOD;
  if (val1 == val2) return 1;
  if (siz % 2 == 1) return 0;
  return ((cmp(idx1, idx2 + siz / 2, siz / 2) &&
           cmp(idx1 + siz / 2, idx2, siz / 2)) ||
          (cmp(idx1, idx2, siz / 2) &&
           cmp(idx1 + siz / 2, idx2 + siz / 2, siz / 2)));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  power[0] = 1;
  hash1[0] = 0;
  hash2[0] = 0;
  for (int i = 0; i < (int)a.size(); ++i) {
    power[i + 1] = (power[i] * base) % MOD;
    hash1[i + 1] =
        (hash1[i] +
         (((long long)(power[i + 1] * (long long)(a[i] - 'a' + 1))) % MOD)) %
        MOD;
    hash2[i + 1] =
        (hash2[i] +
         (((long long)(power[i + 1] * (long long)(b[i] - 'a' + 1))) % MOD)) %
        MOD;
  }
  if (cmp(0, 0, a.size()))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
