#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int inf = 1000000007;
const long long linf = 1000000000000000001LL;
const unsigned long long ulinf = (1ULL << 63) - 10ULL;
const double eps = 0.000001;
const double pi = 3.14159265358979323846;
template <class T>
T abs(T a) {
  return a >= 0 ? a : -a;
}
template <class T>
int sign(T a) {
  return a > eps ? 1 : a < -eps ? -1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T mod(T a, T b) {
  T ret = a % b;
  if (ret < 0) ret += b;
  return ret;
}
template <class T>
T lowbit(T x) {
  return x & -x;
}
long long addmod(long long a, long long b, long long c) {
  return ((a + b) % c + c) % c;
}
long long mulmod(long long a, long long b, long long c) {
  if (b == 0LL) return 0LL;
  long long ret = mulmod(a, b >> 1, c);
  ret = (ret + ret) % c;
  if (b & 1LL) ret = (ret + a) % c;
  return ret;
}
long long powmod(long long a, long long b, long long c) {
  if (b == 0LL) return 1LL;
  long long ret = powmod(a, b >> 1, c);
  ret = ret * ret % c;
  if (b & 1LL) ret = ret * a % c;
  return ret;
}
long long modinv(long long a, long long b) { return powmod(a, b - 2LL, b); }
template <class T>
void maxe(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void mine(T &a, T b) {
  if (a > b) a = b;
}
int iszero(double a) { return a < eps && a > -eps; }
template <class T>
void geti(T &a) {
  a = 0;
  int b = 0;
  char c;
  while ((c = getchar()) == ' ' || c == '\n')
    ;
  if (c == '-')
    b = 1;
  else
    a = c - 48;
  while ((c = getchar()) != ' ' && c != '\n') a = a * 10 + c - 48;
  if (b) a = -a;
}
void fileio_in_out() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
const int N = 222222;
const int M = 100011;
const int K = 20;
const long long md = inf;
int test;
int n, m, k, ans;
char s1[N], s2[N];
int check(int l1, int r1, int l2, int r2) {
  int flag = 1;
  for (int i = l1, j = l2; i <= r1; i++, j++)
    if (s1[i] != s2[j]) {
      flag = 0;
      break;
    }
  if (flag) return 1;
  if ((r1 - l1) & 1) {
    int mid1 = (l1 + r1) >> 1, mid2 = (l2 + r2) >> 1;
    if (check(l1, mid1, l2, mid2) && check(mid1 + 1, r1, mid2 + 1, r2))
      return 1;
    if (check(l1, mid1, mid2 + 1, r2) && check(mid1 + 1, r1, l2, mid2))
      return 1;
  }
  return 0;
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  n = strlen(s1 + 1);
  ans = check(1, n, 1, n);
  puts(ans ? "YES" : "NO");
  return 0;
}
