#include <bits/stdc++.h>
using namespace std;
const int prim = 31, mod1 = 245123729, mod2 = 666013;
pair<int, int> codhash[2][200010], put[200010];
char v[2][200010];
pair<int, int> solve(int ind, int st, int dr) {
  if ((dr - st + 1) % 2) {
    pair<int, int> ret;
    ret.first =
        (codhash[ind][dr].first -
         (1LL * codhash[ind][st - 1].first * put[dr - st + 1].first) % mod1 +
         mod1) %
        mod1;
    ret.second =
        (codhash[ind][dr].second -
         (1LL * codhash[ind][st - 1].second * put[dr - st + 1].second) % mod2 +
         mod2) %
        mod2;
    return ret;
  }
  int mid = (st + dr) / 2;
  pair<int, int> ret, ret1 = solve(ind, st, mid),
                      ret2 = solve(ind, mid + 1, dr);
  if (ret1 > ret2) swap(ret1, ret2);
  ret.first = (1LL * ret1.first * put[dr - mid].first + ret2.first) % mod1;
  ret.second = (1LL * ret1.second * put[dr - mid].second + ret2.second) % mod2;
  return ret;
}
int main() {
  scanf("%s\n%s", v[0] + 1, v[1] + 1);
  int n = strlen(v[0] + 1);
  for (int i = 0; i < 2; i++)
    for (int j = 1; j <= n; j++) {
      codhash[i][j].first =
          (1LL * codhash[i][j - 1].first * prim + v[i][j] - 'a') % mod1;
      codhash[i][j].second =
          (1LL * codhash[i][j - 1].second * prim + v[i][j] - 'a') % mod2;
    }
  put[0] = {1, 1};
  for (int i = 1; i <= n; i++) {
    put[i].first = (1LL * put[i - 1].first * prim) % mod1;
    put[i].second = (1LL * put[i - 1].second * prim) % mod2;
  }
  pair<int, int> ret1 = solve(0, 1, n), ret2 = solve(1, 1, n);
  if (ret1 == ret2)
    printf("YES");
  else
    printf("NO");
  return 0;
}
