#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int base, long long int exponent) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base);
    base = (1LL * base * base);
    exponent >>= 1;
  }
  return ans;
}
string solve(string s) {
  if (s.length() % 2 == 1) return s;
  long long int n = s.length();
  string s1, s2;
  s1 = s.substr(0, n / 2);
  s2 = s.substr(n / 2, n / 2);
  s1 = solve(s1);
  s2 = solve(s2);
  return min(s1 + s2, s2 + s1);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  if (solve(s1) == solve(s2))
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
