#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int N_ = (int)1e6 + 2;
long long Hash_a[N_];
long long Hash_b[N_];
long long pow26[N_];
string a, b;
long long n;
long long get_hash_a(long long x, long long y) {
  return (Hash_a[y] - Hash_a[x - 1] * pow26[y - x + 1] + 1LL * mod * mod) % mod;
}
long long get_hash_b(long long x, long long y) {
  return (Hash_b[y] - Hash_b[x - 1] * pow26[y - x + 1] + 1LL * mod * mod) % mod;
}
bool F(long long L1, long long R1, long long L2, long long R2) {
  int len = R1 - L1 + 1;
  if (len % 2 == 1) {
    return get_hash_a(L1, R1) == get_hash_b(L2, R2);
  } else {
    if (get_hash_a(L1, R1) == get_hash_b(L2, R2)) return true;
    int R_1 = L1 + len / 2 - 1;
    int L_1 = R_1 + 1;
    int R_2 = L2 + len / 2 - 1;
    int L_2 = R_2 + 1;
    if (F(L1, R_1, L_2, R2) && F(L_1, R1, L2, R_2)) return true;
    if (F(L1, R_1, L2, R_2) && F(L_1, R1, L_2, R2)) return true;
    return false;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> a >> b;
  n = a.size();
  pow26[0] = 1;
  for (int i = 1; i <= n; i++) {
    Hash_a[i] = (Hash_a[i - 1] * 26 + (a[i - 1] - 'a' + 1)) % mod;
    Hash_b[i] = (Hash_b[i - 1] * 26 + (b[i - 1] - 'a' + 1)) % mod;
    pow26[i] = pow26[i - 1] * 26;
    pow26[i] %= mod;
  }
  if (F(1, n, 1, n))
    cout << "YES";
  else
    cout << "NO";
}
