#include <bits/stdc++.h>
using namespace std;
bool check_equivalent(char *A, char *B, int x1, int y1, int x2, int y2) {
  if (x1 == y1 && x2 == y2)
    return A[x1] == B[x2];
  else if (x1 == y1 || x2 == y2)
    return false;
  int m1 = (x1 + y1) >> 1, m2 = (x2 + y2) >> 1;
  if ((y1 - x1) % 2)
    return ((check_equivalent(A, B, x1, m1, x2, m2) &&
             check_equivalent(A, B, m1 + 1, y1, m2 + 1, y2)) ||
            (check_equivalent(A, B, x1, m1, m2 + 1, y2) &&
             check_equivalent(A, B, m1 + 1, y1, x2, m2)));
  else {
    for (int i = x1, j = x2; i <= y1; ++i, ++j) {
      if (A[i] != B[j]) return false;
    }
    return true;
  }
}
int main() {
  int i = 0, j;
  char S1[200005], S2[200005];
  cin >> S1;
  cin >> S2;
  if (check_equivalent(S1, S2, 0, strlen(S1) - 1, 0, strlen(S2) - 1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
