#include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int add(long long a, long long b, int m = MOD) {
  return (a % m + b % m + 2 * m) % m;
}
int mul(long long a, long long b, int m = MOD) {
  return ((a % m + m) * (b % m + m)) % m;
}
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int N = 200000 + 5;
int n;
char a[N];
char b[N];
unsigned int p[3][N];
unsigned int B[] = {257, 311};
unsigned int preffix[3][3][N];
pair<unsigned int, unsigned int> getHash(int L, int R, int id) {
  L++;
  R++;
  unsigned int h[2] = {0, 0};
  for (int j = 0; j < 2; j++) {
    h[j] = (preffix[id][j][R] - preffix[id][j][L - 1]);
  }
  return make_pair(h[0], h[1]);
}
void init() {
  for (int j = 0; j < 2; j++) p[j][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      p[j][i] = p[j][i - 1] * B[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      preffix[0][j][i] = preffix[0][j][i - 1] + (a[i - 1] - 'a' + 1) * p[j][i];
      preffix[1][j][i] = preffix[1][j][i - 1] + (b[i - 1] - 'a' + 1) * p[j][i];
    }
  }
}
bool equivalent(int &La, int &Ra, int &Lb, int &Rb) {
  if (La == Ra) {
    return a[La] == b[Lb];
  }
  pair<unsigned int, unsigned int> Ha, Hb;
  Ha = getHash(La, Ra, 0);
  Hb = getHash(Lb, Rb, 1);
  if (La < Lb) {
    Ha.first *= p[0][Lb - La];
    Ha.second *= p[1][Lb - La];
  } else {
    Hb.first *= p[0][La - Lb];
    Hb.second *= p[1][La - Lb];
  }
  if (Ha == Hb) return true;
  int len = Ra - La + 1;
  if (len & 1)
    return false;
  else {
    int ma = (La + Ra) >> 1;
    int maP = ma + 1;
    int mb = (Lb + Rb) >> 1;
    int mbP = mb + 1;
    if (equivalent(La, ma, Lb, mb) and equivalent(maP, Ra, mbP, Rb))
      return true;
    if (equivalent(La, ma, mbP, Rb) and equivalent(maP, Ra, Lb, mb))
      return true;
    return false;
  }
}
int main() {
  scanf("%s", a);
  scanf("%s", b);
  n = strlen(a);
  init();
  int La = 0, Ra = n - 1, Lb = 0, Rb = n - 1;
  if (equivalent(La, Ra, Lb, Rb))
    puts("YES");
  else
    puts("NO");
  return 0;
}
