#include <bits/stdc++.h>
using namespace std;
long double eps = 1e-9;
const long double INF = 1e18;
long long zf(string& s) {
  vector<long long> z(s.length());
  long long l = 0;
  long long r = 0;
  long long res = 0;
  for (long long i = 1; i < s.length(); i++) {
    if (i <= r) {
      z[i] = min(z[i - l], r - i + 1);
    }
    for (; z[i] + i < s.length() && s[z[i]] == s[z[i] + i]; z[i]++)
      ;
    if (z[i] + i >= r) {
      l = i;
      r = i + z[i] - 1;
    }
    res = max(res, z[i]);
  }
  return res;
}
string a;
string b;
bool check(int l, int r, int d) {
  if (d % 2 == 0)
    return (check(l + d / 2, r, d / 2) && check(l, r + d / 2, d / 2)) ||
           (check(l, r, d / 2) && check(l + d / 2, r + d / 2, d / 2));
  else {
    bool flag = true;
    for (int i = 0; i < d; i++) {
      flag = flag && a[l + i] == b[r + i];
    }
    return flag;
  }
}
int main() {
  cin >> a;
  cin >> b;
  if (check(0, 0, a.length())) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
