#include <bits/stdc++.h>
using namespace std;
string a, b;
bool containsEqual(string &a, string &b) {
  int arr[26];
  memset(arr, 0, sizeof(arr));
  int a_len = a.length(), b_len = b.length();
  int i;
  for (i = 0; i < a_len; i++) arr[a[i] - 'a']++;
  for (i = 0; i < b_len; i++) arr[b[i] - 'a']--;
  for (i = 0; i < 26; i++)
    if (arr[i] != 0) return false;
  return true;
}
bool isEquivalent(string a, string b) {
  if (a == b) return true;
  int length = a.length();
  if (length & 1 || !containsEqual(a, b)) return false;
  string firsta = a.substr(0, length / 2), seca = a.substr(length / 2);
  string firstb = b.substr(0, length / 2), secb = b.substr(length / 2);
  return (isEquivalent(firsta, firstb) && isEquivalent(seca, secb)) ||
         (isEquivalent(firsta, secb) && isEquivalent(seca, firstb));
}
int main() {
  cin >> a >> b;
  if (isEquivalent(a, b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
