#include <bits/stdc++.h>
using namespace std;
char s[300000], p[300000];
int n, m;
long long int S[300000], P[300000], R[300000];
multiset<long long int> SET1, SET2;
void solve(int bas, int son) {
  if (bas == son) {
    SET1.insert(S[bas]);
    SET2.insert(P[bas]);
    return;
  }
  int orta = (bas + son) / 2;
  solve(bas, orta);
  solve(orta + 1, son);
  merge(S + bas, S + orta + 1, S + orta + 1, S + son + 1, R + bas);
  for (long long int i = bas; i <= son; i++) S[i] = R[i];
  merge(P + bas, P + orta + 1, P + orta + 1, P + son + 1, R + bas);
  for (long long int i = bas; i <= son; i++) P[i] = R[i];
  long long int hash;
  hash = 0;
  for (long long int i = bas; i <= son; i++)
    hash = (hash * 1000009LL + S[i]) % 1000000007LL;
  SET1.insert(hash);
  hash = 0;
  for (long long int i = bas; i <= son; i++)
    hash = (hash * 1000009LL + P[i]) % 1000000007LL;
  SET2.insert(hash);
}
int main() {
  scanf("%s %s", s + 1, p + 1);
  n = strlen(s + 1);
  m = n;
  while ((m & 1) == 0) m >>= 1;
  long long int hash = 0;
  for (long long int i = 1; i <= n; i++) {
    hash = (hash * 1000009LL + s[i]) % 1000000007LL;
    if (i % m == 0) {
      S[i / m] = hash;
      hash = 0;
    }
  }
  hash = 0;
  for (long long int i = 1; i <= n; i++) {
    hash = (hash * 1000009LL + p[i]) % 1000000007LL;
    if (i % m == 0) {
      P[i / m] = hash;
      hash = 0;
    }
  }
  solve(1, n / m);
  while (SET1.size()) {
    if (*SET1.begin() != *SET2.begin()) return cout << "NO" << endl, 0;
    SET1.erase(SET1.begin());
    SET2.erase(SET2.begin());
  }
  cout << "YES" << endl;
}
