#include <bits/stdc++.h>
using namespace std;
int Read() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
void Print(int a) {
  if (a > 9) Print(a / 10);
  putchar(a % 10 + '0');
}
string a, b;
int dfs(int s1, int t1, int s2, int t2) {
  int len = t1 - s1 + 1;
  if (len & 1) {
    for (int i = 0; i < len; i++) {
      if (a[i + s1] != b[i + s2]) return 0;
    }
    return 1;
  }
  len /= 2;
  if (dfs(s1, s1 + len - 1, s2, s2 + len - 1) &&
      dfs(s1 + len, t1, s2 + len, t2))
    return 1;
  if (dfs(s1 + len, t1, s2, s2 + len - 1) &&
      dfs(s1, s1 + len - 1, s2 + len, t2))
    return 1;
  return 0;
}
int main() {
  while (cin >> a >> b) {
    int len = a.length();
    if (dfs(0, len - 1, 0, len - 1))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
