#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int p = 27;
string s;
int a = 0;
long long int hashnum(int lw, int up) {
  if ((up - lw) % 2 == 0)
    return (((hashnum(lw, (lw + up) / 2) * p) % mod + 1) *
            ((hashnum((lw + up) / 2, up) * p) % mod + 1)) %
           mod;
  long long int res = 0;
  for (int i = lw; i < up; i++) {
    res *= p;
    res %= mod;
    res += (s[i] - 'a');
    res %= mod;
  }
  return res;
}
int main() {
  cin >> s;
  long long int tmp = hashnum(0, s.length());
  cin >> s;
  long long int tmp1 = hashnum(0, s.length());
  if (tmp == tmp1)
    puts("YES");
  else
    puts("NO");
  return 0;
}
