#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define fi first
#define se second
#define pp push_back
#define inarr(n, arr) for(int ax = 0; ax<(n); ax++)cin>>(arr)[ax];
#define rep(aa, bb, cc) for(int aa = bb; aa < cc;aa++)
#define all(x) (x).begin(), (x).end()
#define allr(x) x.rbegin(),(x).rend()
#define Ones(n) __builtin_popcount(n)
#define endl '\n'
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
//#define int long long

void Gamal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};

const double EPS = 1e-9;
const ll N = 2e5 + 5, INF = INT_MAX, MOD = 1e9 + 7, OO = 0X3F3F3F3F3F3F3F3F, LOG = 25;


bool slv(string &a, string &b) {
    if (a == b)
        return true;
    if (a.size() % 2)
        return false;
    string a1 = a.substr(0, a.size() / 2);
    string a2 = a.substr(a.size() / 2, a.size() / 2);
    string b1 = b.substr(0, b.size() / 2);
    string b2 = b.substr(b.size() / 2, b.size() / 2);
    bool ret = slv(a1,b1) && slv(a2,b2);
    if(ret)return true;
    return slv(a1,b2) && slv(a2,b1);
}

void solve() {
    string a, b;
    cin >> a >> b;
    cout << (slv(a, b) ? "YES" : "NO");
}


signed main() {
    Gamal();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}