#include <bits/stdc++.h>
using namespace std;
string s, t;
int cuenta(int n) {
  int cnt = 0;
  while (n) {
    cnt += n & 1;
    n >>= 1;
  }
  return cnt;
}
bool solve(int i, int n, int j, int m) {
  if (n == 1 && m == 1) {
    return s[i] == t[j];
  }
  if (n % 2 == 1 && m % 2 == 1) {
    return s.substr(i, n) == t.substr(j, m);
  }
  if (n != m) return false;
  if (cuenta(i ^ j ^ n ^ m) % 2) {
    bool uu = solve(i, n / 2, j, m / 2);
    bool ud = (uu == true) ? solve(i + n / 2, n / 2, j + m / 2, m / 2) : false;
    if (uu && ud) return true;
  } else {
    bool du = solve(i, n / 2, j + m / 2, m / 2);
    bool dd = (du == true) ? solve(i + n / 2, n / 2, j, m / 2) : false;
    if (du && dd) return true;
  }
  if (cuenta(i ^ j ^ n ^ m) % 2) {
    bool du = solve(i, n / 2, j + m / 2, m / 2);
    bool dd = (du == true) ? solve(i + n / 2, n / 2, j, m / 2) : false;
    if (du && dd) return true;
  } else {
    bool uu = solve(i, n / 2, j, m / 2);
    bool ud = (uu == true) ? solve(i + n / 2, n / 2, j + m / 2, m / 2) : false;
    if (uu && ud) return true;
  }
  return false;
}
int main() {
  cin >> s >> t;
  int freq[26];
  for (int i = 0; i < 26; i++) freq[i] = 0;
  for (int i = 0; i < s.size(); i++) freq[s[i] - 'a']++;
  for (int i = 0; i < t.size(); i++) freq[t[i] - 'a']--;
  for (int i = 0; i < 26; i++) {
    if (freq[i] != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  bool res = solve(0, s.size(), 0, t.size());
  if (res)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
