#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
string a, b;
long long int inp1[200005], ha1[200005], hb1[200005], ha2[200005], inp2[200005],
    hb2[200005], p1 = 31, p2 = 53, m1 = 1e9 + 9, m2 = 1e9 + 7, pow1[200005],
                 pow2[200005];
long long int binpow(long long int a, long long int b, long long int m) {
  a %= m;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int F(long long int la, long long int ha, long long int lb,
                long long int hb) {
  if (la > ha || lb > hb) return 0;
  if (la == ha && lb == hb) {
    if (a[la] == b[lb]) return 1;
    return 0;
  }
  long long int hha1 = ha1[ha], hha2 = ha2[ha], hhb1 = hb1[hb], hhb2 = hb2[hb];
  if (la != 0) {
    hha1 -= ha1[la - 1];
    hha2 -= ha2[la - 1];
  }
  if (lb != 0) {
    hhb1 -= hb1[lb - 1];
    hhb2 -= hb2[lb - 1];
  }
  if (hha1 < 0) hha1 += m1;
  if (hha2 < 0) hha2 += m2;
  if (hhb1 < 0) hhb1 += m1;
  if (hhb2 < 0) hhb2 += m2;
  hha1 = (hha1 * inp1[la]) % m1;
  hha2 = (hha2 * inp2[la]) % m2;
  hhb1 = (hhb1 * inp1[lb]) % m1;
  hhb2 = (hhb2 * inp2[lb]) % m2;
  if (hha1 == hhb1 && hha2 == hhb2) return 1;
  if ((ha - la + 1) % 2 != 0) return 0;
  long long int mida = (la + ha) / 2, midb = (lb + hb) / 2;
  if (F(mida + 1, ha, lb, midb) && F(la, mida, midb + 1, hb)) return 1;
  if (F(la, mida, lb, midb) && F(mida + 1, ha, midb + 1, hb)) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, l;
  cin >> a;
  cin >> b;
  pow1[0] = pow2[0] = 1;
  inp1[0] = inp2[0] = 1;
  for (i = 1; i < 200005; i++) {
    pow1[i] = (pow1[i - 1] * p1) % m1;
    inp1[i] = binpow(pow1[i], m1 - 2, m1);
    pow2[i] = (pow2[i - 1] * p2) % m2;
    inp2[i] = binpow(pow2[i], m2 - 2, m2);
  }
  ha1[0] = ha2[0] = a[0] - 'a' + 1;
  hb1[0] = hb2[0] = b[0] - 'a' + 1;
  for (i = 1; i < a.size(); i++) {
    ha1[i] = (ha1[i - 1] + ((a[i] - 'a' + 1) * pow1[i])) % m1;
    ha2[i] = (ha2[i - 1] + ((a[i] - 'a' + 1) * pow2[i])) % m2;
    hb1[i] = (hb1[i - 1] + ((b[i] - 'a' + 1) * pow1[i])) % m1;
    hb2[i] = (hb2[i - 1] + ((b[i] - 'a' + 1) * pow2[i])) % m2;
  }
  if (F(0, a.size() - 1, 0, b.size() - 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
