#include <bits/stdc++.h>
using namespace std;
int x4[] = {0, 0, -1, 1};
int y4[] = {-1, 1, 0, 0};
int x8[] = {0, 0, -1, 1, -1, 1, -1, 1};
int y8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
string st, tt;
bool equivalent(int s, int t, int len) {
  if (len & 1) {
    for (int i = 0; i < len; i++)
      if (st[s + i] != tt[t + i]) return false;
    return true;
  }
  int n = len / 2;
  bool val2 = equivalent(s, t + n, n) && equivalent(s + n, t, n);
  if (val2) return true;
  return (equivalent(s, t, n) && equivalent(s + n, t + n, n));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> st >> tt;
  bool val = equivalent(0, 0, st.length());
  if (val == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
