#include <bits/stdc++.h>
using namespace std;
const long long base = 2234567897LL;
char s1[200005], s2[200005];
int n, m;
long long h1[200005], h2[200005], power[200005];
inline long long gethash(int k, int l, int r) {
  if (k == 1)
    return h1[r] - h1[l - 1] * power[r - l + 1];
  else
    return h2[r] - h2[l - 1] * power[r - l + 1];
}
inline long long check(int k, int l, int r) {
  int len = r - l + 1;
  if (len % 2 == 1) return gethash(k, l, r);
  int mid = (l + r) >> 1;
  long long hl = check(k, l, mid), hr = check(k, mid + 1, r);
  if (hl > hr) swap(hl, hr);
  return hl * power[len] + hr;
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  n = strlen(s1);
  power[0] = 1;
  for (int i = 1; i <= n; i++) power[i] = power[i - 1] * base;
  for (int i = 1; i <= n; i++) {
    h1[i] = h1[i - 1] * base + s1[i - 1] * s1[i - 1];
    h2[i] = h2[i - 1] * base + s2[i - 1] * s2[i - 1];
  }
  if (check(1, 1, n) == check(2, 1, n))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
