#include <bits/stdc++.h>
using namespace std;
const long long inf = 9e18;
const double pi = acos(-1.0);
const long long M = 1e9 + 7;
const long long N = 1e5 + 5;
bool equ(string s1, string s2) {
  if (s1 == s2) return 1;
  if (s1.size() == 1) return 0;
  string t1, t2, t3, t4;
  if ((long long)s1.size() % 2) return 0;
  long long l = s1.size();
  long long ar1[27] = {0}, ar2[27] = {0}, ar3[27] = {0}, ar4[27] = {0};
  for (long long i = 0; i < l / 2; i++) {
    t1 += s1[i];
    ar1[s1[i] - 'a']++;
    t2 += s1[i + l / 2];
    ar2[s1[i + l / 2] - 'a']++;
    t3 += s2[i];
    ar3[s2[i] - 'a']++;
    t4 += s2[i + l / 2];
    ar4[s2[i + l / 2] - 'a']++;
  }
  long long cnt1(1), cnt2(1), cnt3(1), cnt4(1);
  for (long long i = 0; i < 26; i++) {
    if (ar1[i] != ar3[i]) cnt1 = 0;
    if (ar1[i] != ar4[i]) cnt3 = 0;
    if (ar2[i] != ar4[i]) cnt2 = 0;
    if (ar2[i] != ar3[i]) cnt4 = 0;
  }
  if (cnt1 && cnt2 && equ(t1, t3) && equ(t2, t4)) return 1;
  if (cnt3 && cnt4 && equ(t1, t4) && equ(t2, t3)) return 1;
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  if (equ(s1, s2)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
