#include <bits/stdc++.h>
using namespace std;
const double Pi = 2.0 * acos(0.0);
const double Ex = 2.7182818284;
const int Mod = 1e9 + 7;
const int oo = 2e9 + 1e8;
int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dj[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dik[] = {-1, -1, 1, 1, -2, -2, 2, 2};
int djk[] = {2, -2, 2, -2, 1, -1, 1, -1};
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
long long getInt() {
  long long ret;
  char tmpc;
  bool sign = 0;
  while (tmpc = getchar()) {
    if (tmpc < '0' || tmpc > '9')
      sign = (tmpc == '-');
    else
      break;
  }
  ret = tmpc - '0';
  while (tmpc = getchar(), tmpc >= '0' && tmpc <= '9')
    ret = ret * 10 + tmpc - '0';
  if (sign) ret *= -1;
  return ret;
}
string x, y;
int n;
string solvex(int l, int r) {
  if ((r - l) & 1) return x.substr(l, r - l);
  string a, b;
  a = solvex(l, (l + r) >> 1);
  b = solvex((l + r) >> 1, r);
  if (a > b) swap(a, b);
  return a + b;
}
string solvey(int l, int r) {
  if ((r - l) & 1) return y.substr(l, r - l);
  string a, b;
  a = solvey(l, (l + r) >> 1);
  b = solvey((l + r) >> 1, r);
  if (a > b) swap(a, b);
  return a + b;
}
int main() {
  cin >> x >> y;
  n = (int)x.size();
  if (n & 1) {
    if (x == y)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  if (solvex(0, n) == solvey(0, n))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
