#include <bits/stdc++.h>
using namespace std;
string s, t;
bool equivalent(long long sstart, long long send, long long tstart,
                long long tend) {
  long long m = send - sstart + 1;
  long long n = tend - tstart + 1;
  long long i, j, sum1 = 0, sum2 = 0;
  if (m != n) return false;
  for (i = sstart; i <= send; i++) sum1 += (s[i] - 'a');
  for (j = tstart; j <= tend; j++) sum2 += (t[j] - 'a');
  if (sum1 != sum2) return false;
  bool flag = true;
  i = sstart, j = tstart;
  while (i <= send && j <= tend) {
    if (s[i] != t[j]) {
      flag = false;
      break;
    }
    i++;
    j++;
  }
  if (flag) return true;
  if (sum1 != sum2) return false;
  if (m % 2 != 0) return false;
  if (equivalent(sstart, sstart + m / 2 - 1, tstart, tstart + m / 2 - 1) &&
      equivalent(sstart + m / 2, send, tstart + m / 2, tend))
    return true;
  if (equivalent(sstart, sstart + m / 2 - 1, tstart + m / 2, tend) &&
      equivalent(sstart + m / 2, send, tstart, tstart + m / 2 - 1))
    return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s >> t;
  if (equivalent(0, s.length() - 1, 0, t.length() - 1))
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
