#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
int N;
char a[200005], b[200005];
int P[2] = {1000000007, 1000000009}, A[2] = {234234234, 987654321},
    Apow[2][200005];
int hstr[2][200005];
char str[200005];
void init() {
  for (int t = (0); t < (2); t++) {
    Apow[t][0] = 1;
    for (int i = (1); i < (200005); i++) {
      Apow[t][i] = (long long)Apow[t][i - 1] * A[t] % P[t];
    }
  }
}
void hashit() {
  int n = strlen(str);
  for (int t = (0); t < (2); t++) {
    for (int i = (0); i < (n); i++) {
      hstr[t][i] = ((long long)(i ? hstr[t][i - 1] : 0) * A[t] % P[t] +
                    (str[i] - 'a' + 1)) %
                   P[t];
    }
  }
}
pair<int, int> gethash(int l, int r) {
  int h[2] = {};
  for (int t = (0); t < (2); t++) {
    h[t] = (P[t] + hstr[t][r] -
            (long long)(l ? hstr[t][l - 1] : 0) * Apow[t][r - l + 1] % P[t]) %
           P[t];
  }
  return pair<int, int>(h[0], h[1]);
}
pair<int, int> gen(int l, int r) {
  if ((r - l + 1) % 2) {
    return gethash(l, r);
  }
  int m = (l + r) / 2;
  pair<int, int> hl = gen(l, m);
  pair<int, int> hr = gen(m + 1, r);
  if (hl > hr) swap(hl, hr);
  int h1 = ((long long)hl.first * Apow[0][m - l + 1] % P[0] + hr.first) % P[0];
  int h2 =
      ((long long)hl.second * Apow[1][m - l + 1] % P[1] + hr.second) % P[1];
  return pair<int, int>(h1, h2);
}
int main() {
  init();
  scanf("%s", str);
  int N = strlen(str);
  hashit();
  pair<int, int> h1 = gen(0, N - 1);
  scanf("%s", str);
  hashit();
  pair<int, int> h2 = gen(0, N - 1);
  puts(h1 == h2 ? "YES" : "NO");
  return 0;
}
