#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643383;
long long int Ceil(int a, int b) {
  if (a % b == 0)
    return a / b;
  else
    return (a / b) + 1;
}
long long p = 1000000007;
int f = 0;
int rec(string a, string b, int n) {
  if (a == b) {
    return 1;
  }
  if (n % 2 != 0) {
    if (a != b)
      return 0;
    else
      return 1;
  }
  string a1, b1, a2, b2;
  a1.resize(n / 2);
  b2.resize(n / 2);
  b1.resize(n / 2);
  a2.resize(n / 2);
  for (int i = 0; i < n / 2; i++) {
    a1[i] = a[i];
  }
  for (int i = n / 2; i <= n - 1; i++) {
    a2[i - n / 2] = a[i];
  }
  for (int i = 0; i < n / 2; i++) {
    b1[i] = b[i];
  }
  for (int i = n / 2; i <= n - 1; i++) {
    b2[i - n / 2] = b[i];
  }
  return (((rec(a1, b2, n / 2) && rec(a2, b1, n / 2))) ||
          (rec(a1, b1, n / 2) && rec(a2, b2, n / 2)));
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  string a, b;
  cin >> a >> b;
  int n;
  n = (int)(a).size();
  f = rec(a, b, n);
  if (f == 1) {
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
