#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 200000 + 5;
int n;
char s[maxn], t[maxn];
int ps[maxn][26], pt[maxn][26];
bool dfs(int x, int y, int n) {
  bool ok = true;
  for (int i = 0; i < (n); ++i)
    if (s[x + i] != t[y + i]) {
      ok = false;
      break;
    }
  if (ok) return true;
  if (n & 1) return false;
  n /= 2;
  ok = true;
  for (int j = 0; j < (26); ++j) {
    if (ps[x + n - 1][j] - ps[x - 1][j] != pt[y + n - 1][j] - pt[y - 1][j]) {
      ok = false;
      break;
    }
    if (ps[x + n * 2 - 1][j] - ps[x + n - 1][j] !=
        pt[y + n * 2 - 1][j] - pt[y + n - 1][j]) {
      ok = false;
      break;
    }
  }
  if (ok && dfs(x, y, n) && dfs(x + n, y + n, n)) return true;
  ok = true;
  for (int j = 0; j < (26); ++j) {
    if (ps[x + n - 1][j] - ps[x - 1][j] !=
        pt[y + 2 * n - 1][j] - pt[y + n - 1][j]) {
      ok = false;
      break;
    }
    if (ps[x + n * 2 - 1][j] - ps[x + n - 1][j] !=
        pt[y + n - 1][j] - pt[y - 1][j]) {
      ok = false;
      break;
    }
  }
  return ok && dfs(x, y + n, n) && dfs(x + n, y, n);
}
int main() {
  scanf("%s%s", s + 1, t + 1);
  n = strlen(s + 1);
  for (int i = (1); i <= (n); ++i) {
    for (int j = 0; j < (26); ++j) {
      ps[i][j] = ps[i - 1][j];
      pt[i][j] = pt[i - 1][j];
    }
    ++ps[i][s[i] - 'a'];
    ++pt[i][t[i] - 'a'];
  }
  puts(dfs(1, 1, n) ? "YES" : "NO");
  return 0;
}
