#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n;
char s1[maxn], s2[maxn];
bool check(char *s, int l, int r) {
  int M = l + r >> 1;
  for (int i = l; i <= M; i++) {
    if (s[i] > s[i + M - l + 1]) return true;
    if (s[i] < s[i + M - l + 1]) return false;
  }
  return false;
}
void solve(char *s, int l, int r) {
  if ((r - l + 1) & 1) return;
  int M = l + r >> 1;
  solve(s, l, M);
  solve(s, M + 1, r);
  if (check(s, l, r)) {
    for (int i = l; i <= M; i++) swap(s[i], s[i + M - l + 1]);
  }
}
void Work() {
  solve(s1, 1, n);
  solve(s2, 1, n);
  int ok = 1;
  for (int i = 1; i <= n; i++)
    if (s1[i] != s2[i]) ok = 0;
  puts(ok ? "YES" : "NO");
}
void Init() {
  scanf("%s%s", s1 + 1, s2 + 1);
  n = strlen(s1 + 1);
}
int main() {
  Init();
  Work();
  return 0;
}
