#include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int add(int a, int b, int m = MOD) { return (a + b + m + m) % m; }
int mul(long long a, long long b, int m = MOD) { return (a * b) % m; }
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int N = 200000 + 5;
const int L = 2;
const unsigned int B[] = {257, 311};
int n;
string minimal(string s) {
  if (s.size() & 1) return s;
  string s1 = minimal(s.substr(0, s.size() / 2));
  string s2 = minimal(s.substr(s.size() / 2, s.size() / 2));
  if (s1 < s2) return s1 + s2;
  return s2 + s1;
}
int main() {
  string a, b;
  cin >> a >> b;
  if (minimal(a) == minimal(b))
    puts("YES");
  else
    puts("NO");
  return 0;
}
