#include <bits/stdc++.h>
using namespace std;
const long long int p1 = 313;
const long long int p2 = 99999989;
const long long int inv = 92651747;
const int maxN = 2e5 + 1000;
string s1, s2;
long long int n;
long long int hash1[maxN], hash2[maxN], tavan[maxN];
long long int bsq(long long int paye, long long int t, long long int mod) {
  return tavan[t];
}
void input() {
  cin >> s1 >> s2;
  n = s1.size();
}
void make_hash() {
  long long int psave = p1;
  for (int i = 1; i <= n; i++) {
    hash1[i] = s1[i - 1] * psave + hash1[i - 1];
    hash1[i] %= p2;
    psave *= p1;
    psave %= p2;
  }
  psave = p1;
  for (int i = 1; i <= n; i++) {
    hash2[i] = s2[i - 1] * psave + hash2[i - 1];
    hash2[i] %= p2;
    psave *= p1;
    psave %= p2;
  }
}
bool check(int l1, int r1, int l2, int r2) {
  long long int one = hash1[r1] - hash1[l1 - 1];
  one += p2;
  long long int two = hash2[r2] - hash2[l2 - 1];
  two += p2;
  one %= p2;
  two %= p2;
  one *= bsq(inv, l1 - 1, p2);
  two *= bsq(inv, l2 - 1, p2);
  one %= p2;
  two %= p2;
  if (one != two) return false;
  return s1.substr(l1 - 1, r1 - l1 + 1) == s2.substr(l2 - 1, r2 - l2 + 1);
}
bool equal(int l1, int r1, int l2, int r2) {
  if ((r2 - l2) != (r1 - l1)) return false;
  if (l1 == r1 && l2 == r2) return s1[l1 - 1] == s2[l2 - 1];
  if (check(l1, r1, l2, r2)) return true;
  if ((r1 - l1 + 1) % 2 == 1 || (r2 - l2 + 1) % 2 == 1) return false;
  int mid1 = (l1 + r1) / 2;
  int mid2 = (l2 + r2) / 2;
  if (equal(l1, mid1, mid2 + 1, r2))
    if (equal(mid1 + 1, r1, l2, mid2)) return true;
  if (equal(l1, mid1, l2, mid2))
    if (equal(mid1 + 1, r1, mid2 + 1, r2)) return true;
  return false;
}
void dynamic() {
  tavan[0] = 1;
  tavan[1] = inv;
  for (int i = 2; i <= n; i++) tavan[i] = (tavan[i - 1] * inv) % p2;
}
int main() {
  ios::sync_with_stdio(false);
  input();
  dynamic();
  make_hash();
  if (equal(1, n, 1, n))
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
