#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll md = 1000000007;
ll exp(ll a, ll b) {
  ll r = 1ll;
  while (b > 0) {
    if (b & 1) {
      r = r * (a % md);
      r = (r + md) % md;
    }
    b >>= 1;
    a = (a % md) * (a % md);
    a = (a + md) % md;
  }
  return (r + md) % md;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T Min(T a, T b) {
  if (a < b) return a;
  return b;
}
template <class T>
T Max(T a, T b) {
  if (a > b) return a;
  return b;
}
long long n;
string s1, s2;
bool check(long long i, long long j, long long l) {
  for (ll k = 0; k <= l - 1; ++k)
    if (s1[i + k] != s2[j + k]) return false;
  return true;
}
bool solve(long long i, long long j, long long l) {
  if (l & 1) return check(i, j, l);
  long long d = l >> 1;
  if (rand() & 1)
    return (solve(i, j + d, d) && solve(i + d, j, d)) ||
           (solve(i, j, d) && solve(i + d, j + d, d));
  return (solve(i, j, d) && solve(i + d, j + d, d)) ||
         (solve(i, j + d, d) && solve(i + d, j, d));
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  cin >> s1 >> s2;
  n = (long long)(s1).size();
  cout << (solve(0, 0, n) ? "YES" : "NO");
  cout << '\n';
  return 0;
}
