#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long mod = 1e9 + 7;
inline long long add(long long a, long long b) {
  return (a % mod + b % mod) % mod;
}
inline long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return (a % mod * b % mod) % mod;
}
inline long long power(long long a, long long b, long long MOD) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MOD;
    }
    a = a * a;
    a %= MOD;
    b >>= 1;
  }
  return res;
}
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (long double)(time_p) / CLOCKS_PER_SEC << '\n';
}
bool go(string a, string b) {
  if (a == b) return true;
  long long n1 = a.length();
  long long n2 = b.length();
  if (n1 & 1 || n2 & 1) return false;
  string a1, a2, b1, b2;
  for (long long i = 0; i < n1 / 2; i++) a1 += a[i];
  for (long long i = n1 / 2; i < n1; i++) a2 += a[i];
  for (long long i = 0; i < n2 / 2; i++) b1 += b[i];
  for (long long i = n2 / 2; i < n2; i++) b2 += b[i];
  if (go(a1, b2) && go(a2, b1)) return true;
  if (go(a1, b1) && go(a2, b2)) return true;
  return false;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string a, b;
  cin >> a >> b;
  cout << (go(a, b) ? "YES" : "NO") << '\n';
  time();
  return 0;
}
