#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   string a, b;   map<pair<string, string>, int> m;   int f(string aa, string bb) {     if (aa == bb) return 2;     if (aa.size() % 2) return 1;     if (m[{aa, bb}] != 0) return m[{aa, bb}];     string a1, b1, a2, b2;     for (int i = 0; i < aa.size(); i++) {       if (i < aa.size() / 2) {         a1.push_back(aa[i]);         b1.push_back(bb[i]);       } else {         a2.push_back(aa[i]);         b2.push_back(bb[i]);       }     }     if (f(a1, b1) == 2 && f(a2, b2) == 2) return m[{aa, bb}] = 2;     if (f(a1, b2) == 2 && f(a2, b1) == 2) return m[{aa, bb}] = 2;     return m[{aa, bb}] = 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> a >> b;     if (f(a, b) == 2)       cout <<  YES ;     else       cout <<  NO ;   }   