#include <bits/stdc++.h>
using namespace std;
long long MO[] = {1000000007, 1000000009, 1000000007};
long long PR[] = {137, 173, 17};
long long PO[2][200005];
long long HA[2][200005][2];
string a, b;
struct Node {
  int a1, b1;
  int a2, b2;
  Node(int _a1, int _a2, int _b1, int _b2) {
    a1 = _a1;
    b1 = _b1;
    a2 = _a2;
    b2 = _b2;
  }
  bool operator==(const Node &x) const {
    if (this->a1 == x.a1 && this->a2 == x.a2 && this->b1 == x.b1 &&
        this->b2 == x.b2)
      return true;
    return false;
  }
  bool operator<(const Node &x) const {
    if (this->a1 == x.a1) {
      if (this->a2 == x.a2) {
        if (this->b1 == x.b1) {
          return this->b2 < x.b2;
        }
        return this->b1 < x.b1;
      }
      return this->a2 < x.a2;
    }
    return this->a1 < x.a1;
  }
};
void init(string S, int k) {
  PO[0][0] = PO[1][0] = PO[2][0] = 1;
  for (int h = 0; h < 2; ++h) {
    for (int i = 0; i < S.size(); ++i) {
      if (i) PO[h][i] = (PO[h][i - 1] * PR[h]) % MO[h];
      if (i)
        HA[h][i][k] = ((HA[h][i - 1][k] * PR[h]) + S[i]) % MO[h];
      else
        HA[h][i][k] = S[i];
    }
  }
}
long long getHash(int hId, int l, int r, int k) {
  long long ret = HA[hId][r][k];
  if (l == 0) return ret;
  ret = (ret - (HA[hId][l - 1][k] * PO[hId][(r - l + 1)])) % MO[hId];
  ret = (ret + MO[hId]) % MO[hId];
  return ret;
}
bool same(int l, int r, int l2, int r2) {
  for (int i = 0; i < 2; i++) {
    if (getHash(i, l, r, 0) != getHash(i, l2, r2, 1)) return false;
  }
  return true;
}
map<Node, bool> dp;
bool solve(Node actual) {
  if (dp.find(actual) != dp.end()) return dp[actual];
  if ((actual.a2 - actual.a1 + 1) & 1) {
    return dp[actual] = same(actual.a1, actual.a2, actual.b1, actual.b2);
  }
  if (same(actual.a1, actual.a2, actual.b1, actual.b2)) {
    return dp[actual] = true;
  }
  if ((actual.a2 - actual.a1 + 1) == 2) {
    return (a[actual.a1] == b[actual.b2] && a[actual.a2] == b[actual.b1]);
  }
  int midpoint_a = (actual.a2 + actual.a1) / 2;
  int midpoint_b = (actual.b2 + actual.b1) / 2;
  bool ans = (solve(Node(actual.a1, midpoint_a, midpoint_b + 1, actual.b2)) &&
              solve(Node(midpoint_a + 1, actual.a2, actual.b1, midpoint_b)));
  if (!ans)
    ans = (solve(Node(actual.a1, midpoint_a, actual.b1, midpoint_b)) &&
           solve(Node(midpoint_a + 1, actual.a2, midpoint_b + 1, actual.b2)));
  return dp[actual] = ans;
}
int main() {
  cin >> a;
  init(a, 0);
  cin >> b;
  init(b, 1);
  if (solve(Node(0, a.size() - 1, 0, b.size() - 1)))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
