//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;

bool solve(string s1, string s2){

    if(s1 == s2) return 1;
    if(s1.size() % 2) return 0;
    int n = s1.size() / 2;
    string sl, sr, pl, pr;
    sl = s1.substr(0, n);
    sr = s1.substr(n, n);
    pl = s2.substr(0, n);
    pr = s2.substr(n, n);
    return ((solve(sl, pl) && solve(sr, pr)) || (solve(sl, pr) && solve(sr, pl)));
}

int main(){
    FIO;
    string s1, s2;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){
    if(s1 == s2) return 1;
    if(s1.size() != s2.size() || s1.size() % 2)
        return 0;
    int n = s1.size() / 2;
        return ((solve(s1.substr(0, n), s2.substr(0, n)) &&
                 solve(s1.substr(n, n), s2.substr(n, n))) ||
                (solve(s1.substr(0, n), s2.substr(n, n)) &&
                 solve(s1.substr(n, n), s2.substr(0, n))
               ));

}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){
    if(s1 == s2) return 1;
    if(s1.size() % 2 || s2.size() % 2)
        return 0;
        return ((solve(s1.substr(0, s1.size() / 2), s2.substr(0, s2.size() / 2)) &&
                 solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2))) ||
                (solve(s1.substr(0, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2)) &&
                 solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(0, s2.size() / 2))
               ));

}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){
    if(s1 == s2) return 1;
    if(s1.size() != s2.size() || s1.size() % 2)
        return 0;
    int n = s1.size() / 2;
    string sl, sr, pl, pr;
    sl = s1.substr(0, n);
    sr = s1.substr(n, n);
    pl = s2.substr(0, n);
    pr = s2.substr(n, n);
        return ((solve(sl, pl) &&
                 solve(sr, pr)) ||
                (solve(sl, pr) &&
                 solve(sr, pl)
               ));

}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){

    if(s1 == s2) return 1;
    if(s1.size() % 2) return 0;
    int n = s1.size() / 2;
    string sl, sr, pl, pr;
    sl = s1.substr(0, n);
    sr = s1.substr(n, n);
    pl = s2.substr(0, n);
    pr = s2.substr(n, n);
    return ((solve(sl, pl) && solve(sr, pr)) || (solve(sl, pr) && solve(sr, pl)));
}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
bool solve(string a, string b)
{
    if(a==b)
        return true;
    if(a.size()%2==1)
        return false;
    int n=a.size();
    string e=a.substr(0,n/2);
    string f=b.substr(0,n/2);
    string g=a.substr(n/2);
    string h=b.substr(n/2);
    bool j=solve(e,h) && solve(g,f);
    if(j)
        return true;
    bool i=solve(e,f) && solve(g,h);
    return i||j;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n,sum=0,count=0,m,flag=0,ans=0,k;
    string a,b;
    cin>>a>>b;
    if(solve(a,b))
       cout<<"YES";
    else cout<<"NO";
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;

bool solve(string s1, string s2){

    if(s1 == s2) return 1;
    if(s1.size() % 2) return 0;
    int n = s1.size() / 2;
    string sl, sr, pl, pr;
    sl = s1.substr(0, n);
    sr = s1.substr(n);
    pl = s2.substr(0, n);
    pr = s2.substr(n);
    return ((solve(sl, pl) && solve(sr, pr)) || (solve(sl, pr) && solve(sr, pl)));
}

int main(){
    FIO;
    string s1, s2;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){
    if(s1 == s2) return 1;
    if(s1.size() != s2.size() || s1.size() % 2)
        return 0;

        return ((solve(s1.substr(0, s1.size() / 2), s2.substr(0, s2.size() / 2)) &&
                 solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2))) ||
                (solve(s1.substr(0, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2)) &&
                 solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(0, s2.size() / 2))
               ));

}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;

bool solve(string s1, string s2){

    if(s1 == s2) return 1;
    if(s1.size() % 2) return 0;
    int n = s1.size() / 2;
    string sl, sr, pl, pr;
    sl = s1.substr(0, n);
    sr = s1.substr(n, n);
    pl = s2.substr(0, n);
    pr = s2.substr(n, n);
    return ((solve(sl, pl) && solve(sr, pr)) || (solve(sl, pr) && solve(sr, pl)));
}

int main(){
    FIO;
    string s1, s2;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }

    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;

bool solve(string s1, string s2){

    if(s1 == s2) return 1;
    if(s1.size() % 2 == 1) return 0;
    int n = s1.size();
    string sl, sr, pl, pr;
    sl = s1.substr(0, n/2);
    sr = s1.substr(n/2);
    pl = s2.substr(0, n/2);
    pr = s2.substr(n/2);
    return ((solve(sl, pl) && solve(sr, pr)) || (solve(sl, pr) && solve(sr, pl)));
}

int main(){
    FIO;
    string s1, s2;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;

const int inf = 1e9;
const ll INF = 1e18;
string s1, s2;

bool solve(string s1, string s2){
    if(s1 == s2) return 1;
    if(s1.size() % 2 == 0 && s2.size() % 2 == 0){
        if(solve(s1.substr(0, s1.size() / 2), s2.substr(0, s2.size() / 2)) &&
           solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2))
           )
            return 1;
        if(solve(s1.substr(0, s1.size() / 2), s2.substr(s2.size() / 2, s2.size() / 2)) &&
           solve(s1.substr(s1.size() / 2, s1.size() / 2), s2.substr(0, s2.size() / 2))
           )
           return 1;
    }
    return 0;
}

int main(){
    FIO;
    cin >> s1 >> s2;
    if(solve(s1, s2)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

const int MAXN=200005;
char A[MAXN],B[MAXN];
bool cmp(char x[],char y[],int len)
{
    //printf("%d %d\n",x-A,y-B);
    bool isok=1;
    for(int i=0;i<len;i++)
        if(x[i]!=y[i])isok=0;
    return isok;
}
bool equ(char x[],char y[],int len)
{
    //printf("%d %d %d\n",x-A,y-B,len);
    if(cmp(x,y,len))return 1;
    if(!(len & 1))
        return (equ(x,y+len/2,len/2)&&equ(x+len/2,y,len/2))
                ||(equ(x,y,len/2)&&equ(x+len/2,y+len/2,len/2));
    return 0;
}
int main()
{
    scanf("%s%s",A,B);
    int len=strlen(A);
    printf("%s\n",equ(A,B,len) ? "YES" : "NO");
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

char s[N], t[N];

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        int n = strlen(s);
        if(dfs(n, 0, 0)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

char s[N], t[N];

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    if(n & 1) return false;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        int n = strlen(s);
        if(dfs(n, 0, 0)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool dfs(string s, string t) {
//  cout << s << ' ' << t << endl;
    if(s == t) return true;
    if(s.size() == 1) return false;
    string l1 = s.substr(0, s.size() / 2);
    string l2 = s.substr(s.size() / 2);
    string r1 = t.substr(0, t.size() / 2);
    string r2 = t.substr(t.size() / 2);
    if(dfs(l1, r1) && dfs(l2, r2)) return true;
    if(dfs(l1, r2) && dfs(l2, r1)) return true;
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(s.size() & 1) {
            cout << "NO\n";
            continue;
        }
        if(dfs(s, t)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    if(n & 1) return false;
    return dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r) ||
           dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2);
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(dfs(s.size(), 0, 0)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(dfs(s.size(), 0, 0)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

char s[N], t[N];

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    if(n & 1) return false;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%s%s", s, t)) {
        int n = strlen(s);
        if(dfs(n, 0, 0)) puts("YES");
        else puts("NO");
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

char s[N], t[N];

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    if(n & 1) return false;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%s%s", s, t) == 2) {
        int n = strlen(s);
        if(dfs(n, 0, 0)) puts("YES");
        else puts("NO");
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=200005;
char A[MAXN],B[MAXN];
bool cmp(char x[],char y[],int len)
{
    //printf("%d %d\n",x-A,y-B);
    bool isok=1;
    for(int i=0;i<len;i++)
        if(x[i]!=y[i])isok=0;
    return isok;
}
bool equ(char x[],char y[],int len)
{
    //printf("%d %d %d\n",x-A,y-B,len);
    if(cmp(x,y,len))return 1;
    if(len%2==0)
        return (equ(x,y+len/2,len/2)&&equ(x+len/2,y,len/2))
                ||(equ(x,y,len/2)&&equ(x+len/2,y+len/2,len/2));
    return 0;
}
int main()
{
    scanf("%s%s",A,B);
    int len=strlen(A);
    printf("%s\n",equ(A,B,len) ? "YES" : "NO");
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

const int MAXN=200005;
char A[MAXN],B[MAXN];
bool cmp(char x[],char y[],int len)
{
    //printf("%d %d\n",x-A,y-B);
    bool isok=1;
    for(int i=0;i<len;i++)
        if(x[i]!=y[i])isok=0;
    return isok;
}
bool equ(char x[],char y[],int len)
{
    //printf("%d %d %d\n",x-A,y-B,len);
    if(cmp(x,y,len))return 1;
    if(!(len & 1)
        return (equ(x,y+len/2,len/2)&&equ(x+len/2,y,len/2))
                ||(equ(x,y,len/2)&&equ(x+len/2,y+len/2,len/2));
    return 0;
}
int main()
{
    scanf("%s%s",A,B);
    int len=strlen(A);
    printf("%s\n",equ(A,B,len) ? "YES" : "NO");
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool isEqual(int n, int l, int r) {
//    cout << n << ' ' ;
//    for(int i = 0; i < n; ++i) cout << s[l + i]; cout << ' ';
//    for(int i = 0; i < n; ++i) cout << t[r + i]; cout << endl;
    for(int i = 0; i < n; ++i) {
        if(s[l + i] != t[r + i]) return false;
    }
    return true;
}

bool dfs(int n, int l, int r) {
    if(n == 1) return s[l] == t[r];
    if(isEqual(n, l, r)) return true;
    if(n & 1) return false;
    return dfs(n / 2, l, r) && dfs(n / 2, l + n / 2, r + n / 2) ||
           dfs(n / 2, l, r + n / 2) && dfs(n / 2, l + n / 2, r);
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(dfs(s.size(), 0, 0)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool dfs(string s, string t) {
//  cout << s << ' ' << t << endl;
    if(s == t) return true;
    if(s.size() == 1) return false;
    string l1 = s.substr(0, s.size() / 2);
    string l2 = s.substr(s.size() / 2);
    string r1 = t.substr(0, t.size() / 2);
    string r2 = t.substr(t.size() / 2);
    if(dfs(l1, r1) && dfs(l2, r2)) return true;
    if(dfs(l1, r2) && dfs(l2, r1)) return true;
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(s.size() & 1) {
            cout << (s == t ? "YES" : "NO") << '\n';
            continue;
        }
        if(dfs(s, t)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

string s, t;

bool dfs(string &s, string &t) {
//  cout << s << ' ' << t << endl;
    if(s == t) return true;
    if(s.size() & 1) return false;
    string l1 = s.substr(0, s.size() / 2);
    string l2 = s.substr(s.size() / 2);
    string r1 = t.substr(0, t.size() / 2);
    string r2 = t.substr(t.size() / 2);
    if(dfs(l1, r1) && dfs(l2, r2)) return true;
    if(dfs(l1, r2) && dfs(l2, r1)) return true;
    return false;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//  freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(cin >> s >> t) {
        if(s.size() & 1) {
            cout << (s == t ? "YES" : "NO") << '\n';
            continue;
        }
        if(dfs(s, t)) cout << "YES\n";
        else cout << "NO\n";
//      cout << endl;
    }
    return 0;
}


//
//  Created by TaoSama on 2015-07-22
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 2e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

const int MAXN=200005;
char A[MAXN],B[MAXN];
bool cmp(char x[],char y[],int len)
{
    //printf("%d %d\n",x-A,y-B);
    bool isok=1;
    for(int i=0;i<len;i++)
        if(x[i]!=y[i])isok=0;
    return isok;
}
bool equ(char x[],char y[],int len)
{
    //printf("%d %d %d\n",x-A,y-B,len);
    if(cmp(x,y,len))return 1;
    if(!(len & 1)）
        return (equ(x,y+len/2,len/2)&&equ(x+len/2,y,len/2))
                ||(equ(x,y,len/2)&&equ(x+len/2,y+len/2,len/2));
    return 0;
}
int main()
{
    scanf("%s%s",A,B);
    int len=strlen(A);
    printf("%s\n",equ(A,B,len) ? "YES" : "NO");
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string order(string a)
{
    string s1,s2;
    if(a.length()%2==1)
        return a;
    s1=order(a.substr(0,a.length()/2));
    s2=order(a.substr(a.length()/2,a.length()/2));
    //cout << s1 << "  " << s2 << endl;
    if(s1>s2)
        return s2+s1;
    return s1+s2;
}
int main()
{
    string a,b;
    cin >> a >> b;
    //cout << order(a) << endl << order(b) << endl;
    if(order(a)==order(b))
        cout << "YES\n";
    else
        cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
LL iscorrect(LL i , LL j , LL k , LL m)
{
    LL r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if(i==j)
        return 0;
    if((iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m)) || (iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2)))
      return 1;
    return 0;
}
int main()
{
    cin >> a >> b;
    if(a.length()!=b.length())
    {
        cout << "NO\n";
        return 0;
    }
    if(a==b)
    {
        cout << "YES\n";
        return 0;
    }
    if(a.length()%2==1)
    {
        cout << "NO\n";
        return 0;
    }
    l=a.length();
    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define scann ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
typedef long long int LL;
class node{
public:
    LL ss;
    LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
LL iscorrect(LL i , LL j , LL k , LL m)
{
    LL r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if(i==j || (j-i+1)%2==1)
        return 0;
    return((iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m)) || (iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2)));

}

int main()
{
    scann;
    cin >> a >> b;
    if(a.length()!=b.length())
    {
        cout << "NO\n";
        return 0;
    }
    if(a==b)
    {
        cout << "YES\n";
        return 0;
    }
    if(a.length()%2==1)
    {
        cout << "NO\n";
        return 0;
    }
    l=a.length();
    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
bool iscorrect(int i , int j , int k , int m)
{
    int r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m))
        return 1;
    if(iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2))
        return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
        l=a.length();

    if(l!=b.length())
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
int iscorrect(int i , int j , int k , int m)
{
    int r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m))
        return 1;
    if(iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2))
        return 1;
        return 0;
}

int main()
{
    cin >> a >> b;
    if(a.length()!=b.length())
    {
        cout << "NO\n";
        return 0;
    }
    if(a==b)
    {
        cout << "YES\n";
        return 0;
    }
    if(a.length()%2==1)
    {
        cout << "NO\n";
        return 0;
    }
    l=a.length();
    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
//#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;
void FastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
string a,b;

int l;
bool iscorrect(int i , int j , int k , int m)
{
    int r,t;
    int f=(i+j)/2;
    int g=(k+m)/2;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,f,k,g) && iscorrect(f+1,j,g+1,m))
        return 1;
    if(iscorrect(i,f,g+1,m) && iscorrect(f+1,j,k,g))
        return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
        l=a.length();

    if(l!=b.length())
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;

int l,r,t,m,f,g;
bool iscorrect(int i , int j , int k)
{
     m=k+(j-i);
     f=(i+j)/2;
     g=(k+m)/2;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,f,k) && iscorrect(f+1,j,g+1))
        return 1;
    if(iscorrect(i,f,g+1) && iscorrect(f+1,j,k))
        return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
        l=a.length();

    if(l!=b.length())
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
LL iscorrect(LL i , LL j , LL k , LL m)
{
    LL r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if(i==j || (j-i+1)%2==1)
        return 0;
    return((iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m)) || (iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2)));

}

int main()
{
    cin >> a >> b;
    if(a.length()!=b.length())
    {
        cout << "NO\n";
        return 0;
    }
    if(a==b)
    {
        cout << "YES\n";
        return 0;
    }
    if(a.length()%2==1)
    {
        cout << "NO\n";
        return 0;
    }
    l=a.length();
    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
bool iscorrect(int i , int j , int k , int m)
{
    int r,t;
    int f=(i+j)/2;
    int g=(k+m)/2;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,f,k,g) && iscorrect(f+1,j,g+1,m))
        return 1;
    if(iscorrect(i,f,g+1,m) && iscorrect(f+1,j,k,g))
        return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
        l=a.length();

    if(l!=b.length())
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
//#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;
void FastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
string a,b;

int l;
bool iscorrect(int i , int j , int k)
{
    int r,t;
    int m=k+(j-i);
    int f=(i+j)/2;
    int g=(k+m)/2;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,f,k) && iscorrect(f+1,j,g+1))
        return 1;
    if(iscorrect(i,f,g+1) && iscorrect(f+1,j,k))
        return 1;
    return 0;
}

int main()
{
    cin >> a >> b;
        l=a.length();

    if(l!=b.length())
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

char  a[200001],b[200001];

int l;
bool iscorrect(int i , int j , int k)
{
    int r,t;
     int m=k+(j-i);
     int f=(i+j)/2;
     int g=(k+m)/2;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,f,k) && iscorrect(f+1,j,g+1))
        return 1;
    if(iscorrect(i,f,g+1) && iscorrect(f+1,j,k))
        return 1;
    return 0;
}

int main()
{
    scanf("%s%s",a,b);
        l=strlen(a);

    if(l!=strlen(b))
    {
        cout << "NO\n";
        return 0;
    }

    if(iscorrect(0,l-1,0))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
	LL ss;
	LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;

string a,b;
int l;
bool iscorrect(int i , int j , int k , int m)
{
    int r,t;
    for(r=i,t=k;r<=j;r++,t++)
        if(a[r]!=b[t])
            break;
    if(r==j+1)
        return 1;
    if((j-i+1)%2==1)
        return 0;
    if(iscorrect(i,(i+j)/2,k,(k+m)/2) && iscorrect((i+j)/2+1,j,(k+m)/2+1,m))
        return 1;
    if(iscorrect(i,(i+j)/2,(k+m)/2+1,m) && iscorrect((i+j)/2+1,j,k,(k+m)/2))
        return 1;
        return 0;
}

int main()
{
    cin >> a >> b;
    if(a.length()!=b.length())
    {
        cout << "NO\n";
        return 0;
    }
    if(a==b)
    {
        cout << "YES\n";
        return 0;
    }
    if(a.length()%2==1)
    {
        cout << "NO\n";
        return 0;
    }
    l=a.length();
    if(iscorrect(0,l-1,0,l-1))
        cout << "YES\n";
    else cout << "NO\n";
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int issame(string str1,string str2){
        if(str1 == str2)        return 1;
        int m = str1.length();
        if(m == 1)      return 0;
        return issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(0,m/2));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m & 1)      return 0;
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(m/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){

                return 1;
        }
        int m = str1.length();
        if(m == 1)      return 0;

        if(m & 1){
                int mid = m / 2;
                if( !(str1[mid] == str2[0] || str1[mid] == str2[mid] || str1[mid] == str2[m - 1]) )
                        return 0;
        }
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr((m+1)/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m &= 1)      return 0;
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(m/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m & 1)      return 0;
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(0,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int issame(string str1,string str2){
        if(str1 == str2)        return 1;
        int m = str1.length();
        if(m == 1)      return 0;
        return issame(str1.substr(0,m/2),str2.substr((m+1)/2,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr(0,m/2));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m == 1)      return 0;

        if(m & 1){
                if( issame(str1.substr(0,m/2+1),str2.substr(m/2,m/2+1))&&issame(str1.substr(m/2+1,m/2),str2.substr(0,m/2)) )
                        return 1;
                else if( issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2+1),str2.substr(0,m/2+1)))
                        return 1;
                else if( issame(str1.substr(0,m/2+1),str2.substr(0,m/2+1))&&issame(str1.substr(m/2+1,m/2),str2.substr(m/2+1,m/2)) )
                        return 1;
                else if(issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr(m/2,m/2+1),str2.substr(m/2,m/2+1)))
                        return 1;
                else return 0;
        }else
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr(m/2,m/2),str2.substr(m/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                /*cout<<"# final return\n";
                cout<<"final:"<<str1<<'\n';
                cout<<"final:"<<str2<<'\n';
                cout<<"# final end\n";*/
                return 1;
        }
        int m = str1.length();
        if(m == 1)      return 0;
       /* cout<<"# test begin\n";
        cout<<"test:"<<str1.substr(0,m/2)<<'\n';
        cout<<"test:"<<str1.substr((m+1)/2,m/2)<<'\n';
        cout<<"test:"<<str2.substr(0,m/2)<<'\n';
        cout<<"test:"<<str2.substr((m+1)/2,m/2)<<'\n';
        cout<<"# test end\n";*/

        if(m & 1){
                int mid = m / 2;
                if( !(str1[mid] == str2[0] || str1[mid] == str2[mid] || str1[mid] == str2[m - 1]) )
                        return 0;
        }
        return (issame(str1.substr(0,m/2),str2.substr(m/2,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr((m+1)/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m == 1)      return 0;
        return (issame(str1.substr(0,m/2),str2.substr((m+1)/2,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr((m+1)/2,m/2),str2.substr((m + 1)/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>
#include <string>
using namespace std;
int issame(string str1,string str2){
        if(str1 == str2){
                return 1;
        }
        int m = str1.length();
        if(m == 1)      return 0;
        return (issame(str1.substr(0,m/2),str2.substr((m)/2,m/2))&&issame(str1.substr((m)/2,m/2),str2.substr(0,m/2)))||
               (issame(str1.substr(0,m/2),str2.substr(0,m/2))&&issame(str1.substr((m)/2,m/2),str2.substr((m)/2,m/2)));
}
int main(){
        string str1,str2;
        cin>>str1>>str2;
        cout<<(issame(str1,str2)?"YES":"NO")<<'\n';
        return 0;
}


#include <iostream>

using namespace std;

string a,b;
bool ch(int a1,int a2,int b1,int b2)
{
    for(int i=a1,j=b1;i<=a2;++i,++j)
        if(a[i]!=b[j])
            return false;
    return true;
}
int f(int l1,int r1,int l2,int r2)
{
    int len=r1-l1+1;
    if(len&1)
        return ch(l1,r1,l2,r2);
    return (f(l1,l1+len/2-1,l2,l2+len/2-1)&&f(l1+len/2,r1,l2+len/2,r2)) ||(f(l1,l1+len/2-1,l2+len/2,r2)&&f(l1+len/2,r1,l2,l2+len/2-1));
}
int32_t  main()
{
    cin>>a>>b;
    int n=a.length();
    int m=b.length();
    if(f(0,n-1,0,m-1))
        cout<<"YES";
    else
        cout<<"NO";
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int len,string x,string y)//用来判断x，y是否等价
{
	if(x==y)
		return true;
	if(len%2||len==0)       //当主串不能拆时，不等价
		return false;
	len/=2;
	string	a1=x.substr(0,len);
	string	a2=x.substr(len,len);
	string	b1=y.substr(0,len);
	string	b2=y.substr(len,len);
	if(eq(len,a1,b2)&&eq(len,a2,b1))
		return true;
	if(eq(len,a1,b1)&&eq(len,a2,b2))
		return true;
	return false;
}
int main(void)
{
	cin>>a;
	cin>>b;
	bool p=true;
	int len=a.length();
	if(eq(len,a,b))
		printf("YES\n");
	else
		printf("NO\n");
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int l,string str1,string str2)
{
    if(str1==str2)  return true;
    if(l%2||l==0) return false;
    l/=2;
    string a1=str1.substr(0,l);
    string b1=str1.substr(l,l);
    string a2=str2.substr(0,l);
    string b2=str2.substr(l,l);
    if(eq(l,a1,a2)&&eq(l,b1,b2))
    return true;
    if(eq(l,a1,b2)&&eq(l,a2,b1))
    return true;
      return false;
}

int main(void)
{
    cin>>a;
    cin>>b;
    int len=a.length();
    if(eq(len,a,b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}


#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<string>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
#define OFF(x) memset(x,-1,sizeof x)
#define MEM(x) memset(x,0,sizeof x)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef pair<int,int>pii;
const int maxn=1e5+50;
const int inf =0x3f3f3f3f;
const int MOD =1e9+7;

bool eq(int len,string str1,string str2)
{
    if(str1==str2)  return true;
	if(len%2||len==0) return false;
	string a1,a2,b1,b2;
	int l=len>>1;
	a1=str1.substr(0,l);
	b1=str1.substr(l,l);
	a2=str2.substr(0,l);
	b2=str2.substr(l,l);
	if(eq(l,a1,a2)&&eq(l,b1,b2))
	return true;
	if(eq(l,a1,b2)&&eq(l,b1,a2))
	return true;
	return false;
}

int main()
{
	string a,b;
	int len;
	cin>>a>>b;
	len=a.length();
	if(eq(len,a,b))
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}


#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<string>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
#define OFF(x) memset(x,-1,sizeof x)
#define MEM(x) memset(x,0,sizeof x)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef pair<int,int>pii;
const int maxn=1e5+50;
const int inf =0x3f3f3f3f;
const int MOD =1e9+7;

string a,b;
bool eq(int len,string str1,string str2)
{
    if(str1==str2)  return true;
    if(len%2||len==0) return false;
    string a1,a2,b1,b2;
    int l=len>>1;
    a1=str1.substr(0,l);
    b1=str1.substr(l,l);
    a2=str2.substr(0,l);
    b2=str2.substr(l,l);
    if(eq(l,a1,a2)&&eq(l,b1,b2))
    return true;
    if(eq(l,a1,b2)&&eq(l,b1,a2))
    return true;
    return false;
}

int main()
{
    cin>>a>>b;
    int len=a.length();
    if(eq(len,a,b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int len,string x,string y)
{
    if(x==y)
        return true;
    if(len%2||len==0)
        return false;
    len/=2;
    string  a1=x.substr(0,len);
    string  a2=x.substr(len,len);
    string  b1=y.substr(0,len);
    string  b2=y.substr(len,len);
    if(eq(len,a1,b2)&&eq(len,a2,b1))
        return true;
    if(eq(len,a1,b1)&&eq(len,a2,b2))
        return true;
    return false;
}
int main(void)
{
    cin>>a;
    cin>>b;
    bool p=true;
    int len=a.length();
    if(eq(len,a,b))
        printf("YES\n");
    else
        printf("NO\n");
}


#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<string>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
#define OFF(x) memset(x,-1,sizeof x)
#define MEM(x) memset(x,0,sizeof x)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef pair<int,int>pii;
const int maxn=1e5+50;
const int inf =0x3f3f3f3f;
const int MOD =1e9+7;

string a,b;
bool eq(int l,string str1,string str2)
{
    if(str1==str2)  return true;
    if(l%2||l==0) return false;
    string a1,a2,b1,b2;
    l/=2;
    a1=str1.substr(0,l);
    b1=str1.substr(l,l);
    a2=str2.substr(0,l);
    b2=str2.substr(l,l);
    if(eq(l,a1,a2)&&eq(l,b1,b2))
    return true;
    if(eq(l,a1,b2)&&eq(l,b1,a2))
    return true;
    return false;
}

int main()
{
    cin>>a>>b;
    int len=a.length();
    if(eq(len,a,b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int len,string x,string y)
{
    if(x==y)
        return true;
    if(len%2||len==0)
        return false;
    len/=2;
    string  a1=x.substr(0,len);
    string  a2=x.substr(len,len);
    string  b1=y.substr(0,len);
    string  b2=y.substr(len,len);
    if(eq(len,a1,b2)&&eq(len,a2,b1))
        return true;
    if(eq(len,a1,b1)&&eq(len,a2,b2))
        return true;
    return false;
}
int main(void)
{
    cin>>a;
    cin>>b;
    int len=a.length();
    if(eq(len,a,b))
        printf("YES\n");
    else
        printf("NO\n");
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int l,string str1,string str2)
{
    if(str1==str2)  return true;
    if(l%2||l==0) return false;
    string a1,a2,b1,b2;
    l/=2;
    a1=str1.substr(0,l);
    b1=str1.substr(l,l);
    a2=str2.substr(0,l);
    b2=str2.substr(l,l);
    if(eq(l,a1,a2)&&eq(l,b1,b2))
    return true;
    if(eq(l,a1,b2)&&eq(l,b1,a2))
    return true;
    return false;
}

int main(void)
{
    cin>>a;
    cin>>b;
    int len=a.length();
    if(eq(len,a,b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int l,string str1,string str2)
{
    if(str1==str2)  return true;
    if(l%2||l==0) return false;
    string a1,a2,b1,b2;
    l/=2;
    a1=str1.substr(0,l);
    b1=str1.substr(l,l);
    a2=str2.substr(0,l);
    b2=str2.substr(l,l);
    if(eq(l,a1,a2)&&eq(l,b1,b2))
    return true;
    if(eq(l,a1,b2)&&eq(l,b1,a2))
    return true;
    return false;
}

int main()
{
    cin>>a;
    cin>>b;
    int len=a.length();
    if(eq(len,a,b))
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    return 0;
}


#include <iostream>
#include <string>
#define endl '\n'
using namespace std;

int f(string a,string b)
{
if(a==b)return 1;
if(a.size()%2) return 0;
return f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2)))||f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(0,b.size()/2)));
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <bitset>
#include <queue>
#include <cctype>
#include <unordered_set>
#include <map>
#include <regex>
#include <deque>
#include <stdlib.h>
#define endl '\n'
using namespace std;
/*
    ////                            \\\\
    (upper_bound(mas,mas+n,k)-mas)
    ეს აპერ... აბრუნებს იმ პირველივეშემხვედრ
    ელემენტის იტერატორს, რომელიც მეტია ამ
    ველიუზე ამ შემხვევაში კ-ზე, ის 2 არგუმენტი,
    ფირსტ,ლასტ დიაპაზონია;
    და ვაკლებ სახელს, რადგან ინტებზე დავიყვანო,
    //სატთან პირველი ელემენტი მე ნული მაქვს და
    //ეგეცაა გასავალისწინებელი
    \\\\                            ////
    pair<int,int>p{1,3};
    vector<int>v={1,2,3,89};

    for(au,to i:v)
    cout<<i<<i<<" ";
    cout<<__gcd(18, 27);
*/
bool f(string a,string b)
{
if(a==b)return true;
if(a.size()&1) return false;
if((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))))return true;
else return false;
}
int main()
{
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include<iostream>
using namespace std;
#include<string>
int is_eq(string a, string b){
	if(a==b) return 1;
	if(a.size()%2) return 0;
	return is_eq(a.substr(0,a.size()/2),b.substr(b.size()/2,b.size()/2)) && is_eq(a.substr(a.size()/2,a.size()/2),b.substr(0,b.size()/2)) ||
		is_eq(a.substr(0,a.size()/2),b.substr(0,b.size()/2)) && is_eq(a.substr(a.size()/2,a.size()/2),b.substr(b.size()/2,b.size()/2));
}
int main()
{
	string a,b;
	cin>>a>>b;
	if(is_eq(a,b)) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#define endl '\n'
using namespace std;

int f(string a,string b)
{
if(a==b)return 1;
if(a.size()%2) return 0;
return (f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2)))||f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2)))));
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
#define endl '\n'
using namespace std;
bool f(string a,string b)
{
if(a==b)return true;
if(a.size()&1) return false;
if((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))))return true;
else return false;
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <bitset>
#include <queue>
#include <cctype>
#include <unordered_set>
#include <map>
#include <regex>
#include <deque>
#include <stdlib.h>
#define endl '\n'
using namespace std;
/*
    ////                            \\\\
    (upper_bound(mas,mas+n,k)-mas)
    ეს აპერ... აბრუნებს იმ პირველივეშემხვედრ
    ელემენტის იტერატორს, რომელიც მეტია ამ
    ველიუზე ამ შემხვევაში კ-ზე, ის 2 არგუმენტი,
    ფირსტ,ლასტ დიაპაზონია;
    და ვაკლებ სახელს, რადგან ინტებზე დავიყვანო,
    //სატთან პირველი ელემენტი მე ნული მაქვს და
    //ეგეცაა გასავალისწინებელი
    \\\\                            ////
    pair<int,int>p{1,3};
    vector<int>v={1,2,3,89};

    for(au,to i:v)
    cout<<i<<i<<" ";
    cout<<__gcd(18, 27);
*/
int f(string a,string b)
{
if(a==b)return 1;
if(a.size()&1) return 0;
if((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))))return 1;
else return 0;
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <bitset>
#include <queue>
#include <cctype>
#include <unordered_set>
#include <map>
#include <regex>
#include <deque>
#include <stdlib.h>
#define endl '\n'
using namespace std;
/*
    ////                            \\\\
    (upper_bound(mas,mas+n,k)-mas)
    ეს აპერ... აბრუნებს იმ პირველივეშემხვედრ
    ელემენტის იტერატორს, რომელიც მეტია ამ
    ველიუზე ამ შემხვევაში კ-ზე, ის 2 არგუმენტი,
    ფირსტ,ლასტ დიაპაზონია;
    და ვაკლებ სახელს, რადგან ინტებზე დავიყვანო,
    //სატთან პირველი ელემენტი მე ნული მაქვს და
    //ეგეცაა გასავალისწინებელი
    \\\\                            ////
    pair<int,int>p{1,3};
    vector<int>v={1,2,3,89};

    for(au,to i:v)
    cout<<i<<i<<" ";
    cout<<__gcd(18, 27);
*/
bool f(string a,string b)
{
if(a==b)return true;
if(a.size()&1) return false;
return ((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))));
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <bitset>
#include <queue>
#include <cctype>
#include <unordered_set>
#include <map>
#include <regex>
#include <deque>
#include <stdlib.h>
#define endl '\n'
using namespace std;
/*
    ////                            \\\\
    (upper_bound(mas,mas+n,k)-mas)
    ეს აპერ... აბრუნებს იმ პირველივეშემხვედრ
    ელემენტის იტერატორს, რომელიც მეტია ამ
    ველიუზე ამ შემხვევაში კ-ზე, ის 2 არგუმენტი,
    ფირსტ,ლასტ დიაპაზონია;
    და ვაკლებ სახელს, რადგან ინტებზე დავიყვანო,
    //სატთან პირველი ელემენტი მე ნული მაქვს და
    //ეგეცაა გასავალისწინებელი
    \\\\                            ////
    pair<int,int>p{1,3};
    vector<int>v={1,2,3,89};

    for(au,to i:v)
    cout<<i<<i<<" ";
    cout<<__gcd(18, 27);
*/
bool f(string a,string b)
{
if(a==b)return true;
if(a.size()&1) return false;
if((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))))return true;
else return false;
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
#define endl '\n'
using namespace std;

int f(string a,string b)
{
if(a==b)return 1;
if(a.size()&1) return 0;
return ((f((a.substr(0,a.size()/2)),(b.substr(0,b.size()/2)))&&f((a.substr(a.size()/2)),(b.substr(b.size()/2))))||(f((a.substr(0,a.size()/2)),(b.substr(b.size()/2)))&&(f((a.substr(a.size()/2)),(b.substr(0,b.size()/2))))));
}
int main()
{ ios_base::sync_with_stdio(false);cin.tie(0);
     string a,b;
     cin>>a>>b;
     if(f(a,b))cout<<"YES";
     else cout<<"NO";

    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

string smallest(string s, int n){
    if (n % 2 == 1) return s;
    string s1 = smallest(s.substr(0, n / 2), n / 2);
    string s2 = smallest(s.substr(n / 2, n / 2), n / 2);
    if (s1 < s2) return s1 + s2;
    return s2 + s1;
}

int main(){
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (smallest(a, a.length()) == smallest(b, b.length())) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

bool cnt(string a, string b){
    //cout << a << ' ' << b << endl;
    vector <int> x(26, 0);
    for (int i = 0; i < a.length(); i++){
        x[a[i] - 'a']++;
        x[b[i] - 'a']--;
    }
    for (int i = 0; i < 26; i++){
        if (x[i]) return false;
    }
    return true;
}

bool is_equal(string a, string b){
    //cout << a << ' ' << b << endl;
    int n = a.length();
    if (n % 2 == 1){
        for (int i = 0; i < n; i++)
            if (a[i] != b[i])
                return false;
        return true;
    }
    string a1 = a.substr(0, n / 2), a2 = a.substr(n / 2, n / 2);
    string b1 = b.substr(0, n / 2), b2 = b.substr(n / 2, n / 2);
    bool x, y;
    if (cnt(a1, b1) && cnt(a2, b2)) x = is_equal(a1, b1) && is_equal(a2, b2);
    else x = false;
    if (cnt(a1, b2) && cnt(a2, b1)) y = is_equal(a1, b2) && is_equal(a2, b1);
    else y = false;
    return (x || y);
}

int main(){
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (is_equal(a, b)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

string a, b;

bool is_equal(int a_begin, int b_begin, int n){
    if (n % 2 == 1){
        for (int i = 0; i < n; i++){
            if (a[a_begin + i] != b[b_begin + i])
                return false;
        }
        return true;
    }
    bool x = (is_equal(a_begin, b_begin, n / 2) && is_equal(a_begin + n / 2, b_begin + n / 2, n / 2));
    bool y = (is_equal(a_begin, b_begin + n / 2, n / 2) && is_equal(a_begin + n / 2, b_begin, n / 2));
    return x || y;
}

int main(){
    getline(cin, a);
    getline(cin, b);
    int n = a.length();
    if (is_equal(0, 0, n)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

string a, b;

bool is_equal(int a_begin, int b_begin, int n){
    if (n % 2 == 1){
        for (int i = 0; i < n; i++){
            if (a[a_begin + i] != b[b_begin + i])
                return false;
        }
        return true;
    }
    int cnt = 0;
    vector<int> ax(26, 0), bx(26, 0);
    for (int i = 0; i < n; i++){
        if (a[a_begin + i] == b[b_begin + i]) cnt++;
        ax[a[a_begin + i] - 'a']++;
        bx[b[b_begin + i] - 'a']++;
    }
    if (cnt == n) return true;
    cnt = 0;
    for (int i = 0; i < 26; i++){
        if (ax[i] == bx[i]) cnt++;
    }
    if (cnt != 26) return false;
    bool x = (is_equal(a_begin, b_begin, n / 2) && is_equal(a_begin + n / 2, b_begin + n / 2, n / 2));
    bool y = (is_equal(a_begin, b_begin + n / 2, n / 2) && is_equal(a_begin + n / 2, b_begin, n / 2));
    return x || y;
}

int main(){
    getline(cin, a);
    getline(cin, b);
    int n = a.length();
    if (is_equal(0, 0, n)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

bool is_equal(string a, string b){
    //cout << a << ' ' << b << endl;
    int n = a.length();
    if (n % 2 == 1){
        for (int i = 0; i < n; i++)
            if (a[i] != b[i])
                return false;
        return true;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (a[i] == b[i]){
            cnt++;
        }
    }
    if (cnt == n) return true;
    //cout << 1;
    string a1 = a.substr(0, n / 2), a2 = a.substr(n / 2, n / 2);
    string b1 = b.substr(0, n / 2), b2 = b.substr(n / 2, n / 2);
    return ((is_equal(a1, b1) && is_equal(a2, b2)) || (is_equal(a1, b2) && is_equal(a2, b1)));
}

int main(){
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (is_equal(a, b)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

bool is_equal(string a, string b){
    //cout << a << ' ' << b << endl;
    int n = a.length();
    if (n % 2 == 1){
        for (int i = 0; i < n; i++)
            if (a[i] != b[i])
                return false;
        return true;
    }
    string a1 = a.substr(0, n / 2), a2 = a.substr(n / 2, n / 2);
    string b1 = b.substr(0, n / 2), b2 = b.substr(n / 2, n / 2);
    return ((is_equal(a1, b1) && is_equal(a2, b2)) || (is_equal(a1, b2) && is_equal(a2, b1)));
}

int main(){
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (is_equal(a, b)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

bool is_equal(string a, string b){
    //cout << a << ' ' << b << endl;
    int n = a.length();
    if (n % 2 == 1){
        return (a == b);
    }
    string a1 = a.substr(0, n / 2), a2 = a.substr(n / 2, n / 2);
    string b1 = b.substr(0, n / 2), b2 = b.substr(n / 2, n / 2);
    bool x, y;
    x = is_equal(a1, b1) && is_equal(a2, b2);
    y = is_equal(a1, b2) && is_equal(a2, b1);
    return (x || y);
}

int main(){
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (is_equal(a, b)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <string>

using namespace std;

string a, b;

bool is_equal(int a_begin, int b_begin, int n){
    if (n % 2 == 1){
        for (int i = 0; i < n; i++){
            if (a[a_begin + i] != b[b_begin + i])
                return false;
        }
        return true;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (a[a_begin + i] == b[b_begin + i]) cnt++;
    }
    if (cnt == n) return true;
    bool x = (is_equal(a_begin, b_begin, n / 2) && is_equal(a_begin + n / 2, b_begin + n / 2, n / 2));
    bool y = (is_equal(a_begin, b_begin + n / 2, n / 2) && is_equal(a_begin + n / 2, b_begin, n / 2));
    return x || y;
}

int main(){
    getline(cin, a);
    getline(cin, b);
    int n = a.length();
    if (is_equal(0, 0, n)) cout << "YES";
    else cout << "NO";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    bool equivalent=false;
    if(a.size()%2!=0){
        if(a==b){
            return true;
        }
        else{
            return false;
        }
    }
    if(a==b){
        return true;
    }
    else{
        string a1=a.substr(0,a.size()/2);
        string b1=b.substr(0,b.size()/2);
        string a2=a.substr(a.size()/2,a.size()/2);
        string b2=b.substr(b.size()/2,b.size()/2);
        return (equivalen(a1,b2) && equivalen(a2,b1)) || (equivalen(a1,b1)&&equivalen(a2,b2));
    }
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }
    else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    bool equivalent=false;
    if(a.size()%2!=0){
        if(a==b){
            return true;
        }
        else{
            return false;
        }
    }
    if(a==b){
        return true;
    }
    else{
        string a1=a.substr(0,a.size()/2);
        string b1=b.substr(0,b.size()/2);
        string a2=a.substr(a.size()/2,a.size()/2);
        string b2=b.substr(b.size()/2,b.size()/2);
        return (equivalen(a1,b1)&&equivalen(a2,b2))||(equivalen(a1,b2) && equivalen(a2,b1));
    }
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }
    else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    if(a==b) return true;
    if(a.size()%2!=0) return false;
    else{
        return (equivalen(a.substr(0,a.size()/2),b.substr(0,b.size()/2))&&equivalen(a.substr(a.size()/2,a.size()/2),b.substr(b.size()/2,b.size()/2)))||(equivalen(a.substr(0,a.size()/2),b.substr(b.size()/2,b.size()/2)) && equivalen(a.substr(a.size()/2,a.size()/2),b.substr(0,b.size()/2)));
    }
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }

else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    bool equivalent=false;
    if(a==b) return true;
    if(a.size()%2!=0) return false;
    else{
        string a1=a.substr(0,a.size()/2);
        string b1=b.substr(0,b.size()/2);
        string a2=a.substr(a.size()/2,a.size()/2);
        string b2=b.substr(b.size()/2,b.size()/2);
        return (equivalen(a1,b1)&&equivalen(a2,b2))||(equivalen(a1,b2) && equivalen(a2,b1));
    }
    }
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }

else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()%2!=0){
        if(s1.size()==s2.size()){
            cout<<"YES";
            return 0;
        }
        else{
            cout<<"NO";
            return 0;
        }
    }
    if(s1==s2){
        cout<<"YES";
        return 0;
    }
    else{
        string a1=s1.substr(0,s1.size()/2);
        string b1=s1.substr(s1.size()/2,s1.size()/2);
        string a2=s2.substr(0,s2.size()/2);
        string b2=s2.substr(s2.size()/2,s2.size()/2);
        sort(a1.begin(),a1.end());
        sort(b1.begin(),b1.end());
        sort(a2.begin(),a2.end());
        sort(b2.begin(),b2.end());
        if((a1==b1 && a2==b2) || (a1==b2 && a2==b1)){
            cout<<"YES";
            return 0;
        }
        else cout<<"NO";
    }
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    bool equivalent=false;
    if(a.size()%2!=0){
        if(a==b){
            return true;
        }
        else{
            return false;
        }
    }
    else {if(a==b){
        return true;
    }
    else{
        string a1=a.substr(0,a.size()/2);
        string b1=b.substr(0,b.size()/2);
        string a2=a.substr(a.size()/2,a.size()/2);
        string b2=b.substr(b.size()/2,b.size()/2);
        return (equivalen(a1,b1)&&equivalen(a2,b2))||(equivalen(a1,b2) && equivalen(a2,b1));
    }
    }
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }
    else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()%2!=0){
        if(s1==s2){
            cout<<"YES";
            return 0;
        }
        else{
            cout<<"NO";
            return 0;
        }
    }
    if(s1==s2){
        cout<<"YES";
        return 0;
    }
    else{
        string a1=s1.substr(0,s1.size()/2);
        string b1=s1.substr(s1.size()/2,s1.size()/2);
        string a2=s2.substr(0,s2.size()/2);
        string b2=s2.substr(s2.size()/2,s2.size()/2);
        sort(a1.begin(),a1.end());
        sort(b1.begin(),b1.end());
        sort(a2.begin(),a2.end());
        sort(b2.begin(),b2.end());
        if((a1==b1 && a2==b2) || (a1==b2 && a2==b1)){
            cout<<"YES";
            return 0;
        }
        else cout<<"NO";
    }
}


#include<bits/stdc++.h>
using namespace std;
bool equivalen(string a,string b)
{
    if(a==b) return true;
    if(a.size()%2!=0) return false;
    else{
        string a1=a.substr(0,a.size()/2);
        string b1=b.substr(0,b.size()/2);
        string a2=a.substr(a.size()/2,a.size()/2);
        string b2=b.substr(b.size()/2,b.size()/2);
        return (equivalen(a1,b1)&&equivalen(a2,b2))||(equivalen(a1,b2) && equivalen(a2,b1));
    }
    }

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(equivalen(s1,s2)==true){
        cout<<"YES";
    }

else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1==s2){
        cout<<"YES";
        return 0;
    }
    else{
        string a1=s1.substr(0,s1.size()/2);
        string b1=s1.substr(s1.size()/2,s1.size()/2);
        string a2=s2.substr(0,s2.size()/2);
        string b2=s2.substr(s2.size()/2,s2.size()/2);
        sort(a1.begin(),a1.end());
        sort(b1.begin(),b1.end());
        sort(a2.begin(),a2.end());
        sort(b2.begin(),b2.end());
        if((a1==b1 && a2==b2) || (a1==b2 && a2==b1)){
            cout<<"YES";
            return 0;
        }
        else cout<<"NO";
    }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MAX_C 200001

char a[MAX_C], b[MAX_C];

bool check(int p1, int p2, int s) {
  if (s%2) {
    for (int i = 0; i < s; i++) {
      if (a[p1+i] != b[p2+i]) return 0;
    }
    return 1;
  }
  int a1 = p1, a2 = p1+s/2;
  int b1 = p2, b2 = p2+s/2;
  return ( (check(a1, b1, s/2) &&
        check(a2, b2, s/2))
       ||
       (check(a1, b2, s/2) &&
        check(a2, b1, s/2)) );
}

int main() {
  scanf("%s %s", a, b);
  if (check(0, 0, strlen(a))) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

bool check(string a, string b) {
  int n = a.size();
  if (n%2) return a == b;
  return ( (check(a.substr(0,n/2), b.substr(0, n/2)) &&
             (check(a.substr(n/2, n/2), b.substr(n/2, n/2))))
          ||
            ((check(a.substr(0,n/2), b.substr(n/2, n/2)) &&
              check(b.substr(0,n/2), a.substr(n/2, n/2)))) );
}

int main() {
  string a, b;
  cin >> a >> b;
  if (check(a, b)) {
    std::cout << "YES" << std::endl;
  }else {
    std::cout << "NO" << std::endl;
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MAX_C 200001

char a[MAX_C], b[MAX_C];

bool check(char *p1, char *p2, int s) {
  if (s%2) {
    for (int i = 0; i < s; i++) {
      if (p1[i] != p2[i]) return false;
    }
    return true;
  }
  return ( (check(p1, p2, s/2) &&
        check(p1+s/2, p2+s/2, s/2))
       ||
       (check(p1, p2+s/2, s/2) &&
        check(p1+s/2, p2, s/2)) );
}

int main() {
  scanf("%s %s", a, b);
  if (check(a, b, strlen(a))) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MAX_C 200001

char a[MAX_C], b[MAX_C];

bool check(char *p1, char *p2, int s) {
  if (s%2) {
    for (int i = 0; i < s; i++) {
      if (p1[i] != p2[i]) return false;
    }
    return true;
  }
  return ( (check(p1, p2+s/2, s/2) &&
        check(p1+s/2, p2, s/2))
       ||
       (check(p1, p2, s/2) &&
        check(p1+s/2, p2+s/2, s/2)));
}

int main() {
  scanf("%s %s", a, b);
  if (check(a, b, strlen(a))) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

ll getTimeUS() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (ll)tv.tv_sec*1000000+(ll)tv.tv_usec;
}

namespace g {
  string a, b;
  ll startT;
}

ll cnt = 0;
bool check(int p1, int p2, int s) {
  if (s%2) {
    return g::a.substr(p1, s) == g::b.substr(p2, s);
  }
  if (getTimeUS()-g::startT >= 1800000) {
    puts("NO");
    exit(1);
  }
  int a1 = p1, a2 = p1+s/2;
  int b1 = p2, b2 = p2+s/2;
  if (rand()%2) {
    return ( (check(a1, b1, s/2) &&
          (check(a2, b2, s/2)))
         ||
         (check(a1, b2, s/2) &&
          check(a2, b1, s/2)) );
  }else {
    return (  (check(a1, b2, s/2) &&
          check(a2, b1, s/2))
          ||
          (check(a1, b1, s/2) &&
           (check(a2, b2, s/2))));
  }
}

int main() {
  srand((unsigned int)time(NULL));
  g::startT = getTimeUS();
  cin >> g::a >> g::b;
  if (check(0, 0, g::a.size())) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

namespace g {
  string a, b;
}

bool bsubstr(int p1, int p2, int s) {
  for (int i = 0; i < s; i++) {
    if (g::a[p1+i] != g::b[p2+i]) return false;
  }
  return true;
}

ll cnt = 0;
bool check(int p1, int p2, int s) {
  if (s%2) {
    return bsubstr(p1, p2, s);
  }
  int a1 = p1, a2 = p1+s/2;
  int b1 = p2, b2 = p2+s/2;
  return ( (check(a1, b1, s/2) &&
        (check(a2, b2, s/2)))
       ||
       (check(a1, b2, s/2) &&
        check(a2, b1, s/2)) );
}

int main() {
  cin >> g::a >> g::b;
  if (check(0, 0, g::a.size())) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MAX_C 200001

char a[MAX_C], b[MAX_C];

bool check(char *p1, char *p2, int s) {
  if (s&1) {
    for (int i = 0; i < s; i++) {
      if (p1[i] != p2[i]) return false;
    }
    return true;
  }
  return ( (check(p1, p2+(s>>1), s>>1) &&
        check(p1+(s>>1), p2, s>>1))
       ||
       (check(p1, p2, s>>1) &&
        check(p1+(s>>1), p2+(s>>1), s>>1)));
}

int main() {
  scanf("%s %s", a, b);
  if (check(a, b, strlen(a))) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MAX_C 200001

char a[MAX_C], b[MAX_C];

bool check(int p1, int p2, int s) {
  if (s%2) {
    for (int i = 0; i < s; i++) {
      if (a[p1+i] != b[p2+i]) return false;
    }
    return true;
  }
  int a1 = p1, a2 = p1+s/2;
  int b1 = p2, b2 = p2+s/2;
  return ( (check(a1, b1, s/2) &&
        check(a2, b2, s/2))
       ||
       (check(a1, b2, s/2) &&
        check(a2, b1, s/2)) );
}

int main() {
  scanf("%s %s", a, b);
  if (check(0, 0, strlen(a))) {
    puts("YES");
  }else {
    puts("NO");
  }
}


#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

bool check(string a, string b) {
  int n = a.size();
  if (n%2) return a == b;
  return (check(a.substr(0,n/2), b.substr(n/2, n/2)) &&
          check(b.substr(0,n/2), a.substr(n/2, n/2)));
}

int main() {
  string a, b;
  cin >> a >> b;
  if (check(a, b)) {
    std::cout << "YES" << std::endl;
  }else {
    std::cout << "NO" << std::endl;
  }
}


#include <iostream>
using namespace std;

int main()
{
    int i = 0, t;
    long int L, v, l, r;
    cin >> t;
    for(i = 0; i<t; i++)
    {
        cin>>L>>v>>l>>r;
        cout<< L/v - (r - l +1)/v<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int i = 0, t;
    long int L, v, l, r;
    cin >> t;
    for(i = 0; i<t; i++)
    {
        cin>>L>>v>>l>>r;
        cout<< L/v - r/v - (l-1)/v<<endl;
    }
    return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
		if(V == 2){
			if(l%2 == 0) ans -= (r - l)/V + 1;
			else ans -= (r - l)/V;
		}
		else if(V == 1){
			ans -= r - l + 1;
		}
		else{
			int segL = r - l;
			ans -= segL/V;
			if(l%V == 0) ans--;
			if(r%V == 0) ans--;
			if(r%V == 0 && l%V == 0) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
		if(V == 2){
			if(l%2 == 0) ans -= (r - l)/V + 1;
			else ans -= (r - l)/V;
		}
		else if(V == 1){
			ans -= r - l + 1;
		}
		else{
			int pos = 1;
			while(pos < l) pos += V;
			while(pos <= r) {
				ans--;
				pos += V;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
//		if(V == 2){
//			if(l%2 == 0) ans -= (r - l)/V + 1;
//			else ans -= (r - l)/V;
//		}
//		else if(V == 1){
//			ans -= r - l + 1;
//		}
//		else{
			//int segL = r - l;
			//ans -= segL/V;
			//if(l%V == 0) ans--;
			//if(r%V == 0) ans--;
			//if(r%V == 0 && l%V == 0) ans++;
//			int pos = 0;
//			pos = (l/V + 1) * V;
//			if(pos == l + V) pos -= V;
//			int seg = r - pos;
//			if(pos <= r){
//				ans--;
//				ans -= seg/V;
//			}
		//}
		ans = ans - r/V + l/V;
		if(!(l%V)) ans--;
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
		if(V == 2){
			if(l%2 == 0) ans -= (r - l)/V + 1;
			else ans -= (r - l)/V;
		}
		else if(V == 1){
			ans -= r - l + 1;
		}
		else{
			//int segL = r - l;
			//ans -= segL/V;
			//if(l%V == 0) ans--;
			//if(r%V == 0) ans--;
			//if(r%V == 0 && l%V == 0) ans++;
			int pos = 0;
			while(pos < l) pos += V;
			int seg = r - pos;
			if(pos <= r) ans--;
			ans -= seg/V;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
		if(V == 2){
			if(l%2 == 0) ans -= (r - l)/V + 1;
			else ans -= (r - l)/V;
		}
		else if(V == 1){
			ans -= r - l + 1;
		}
		else{
			//int segL = r - l;
			//ans -= segL/V;
			//if(l%V == 0) ans--;
			//if(r%V == 0) ans--;
			//if(r%V == 0 && l%V == 0) ans++;
			int pos = 0;
			pos = (l/V + 1) * V;
			if(pos == l + V) pos -= V;
			int seg = r - pos;
			if(pos <= r) ans--;
			ans -= seg/V;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>

using namespace std;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int L, V, l, r, ans = 0;
		scanf("%d%d%d%d", &L, &V, &l, &r);
		ans = L/V;
		if(V == 2){
			if(l%2 == 0) ans -= (r - l)/V + 1;
			else ans -= (r - l)/V;
		}
		else if(V == 1){
			ans -= r - l + 1;
		}
		else{
			int pos = 0;
			while(pos < l) pos += V;
			while(pos <= r) {
				ans--;
				pos += V;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<iostream>

#define ll long long
#define endl '\n'

using namespace std;

ll t,L[10005],v[10005],l[10005],r[10005],sum=0;
	//�ت��a  �i�QV�㰣  �C����m l~r
	//p�i�Qv�㰣 �L�C��

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>L[i]>>v[i]>>l[i]>>r[i];
	}
	for(int i=0;i<t;i++){
		if(L[i]==r[i]){
			cout<<"0"<<endl;
			return 0;
		}
		sum=0;
		for(int y=1;y<=L[i];y++){
			if(y>=l[i]&&y<=r[i]){
				continue;
			}
			else if(y%v[i]==0){
				sum++;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}


#include<iostream>

#define ll long long
#define endl '\n'

using namespace std;

ll t,L[10005],v[10005],l[10005],r[10005],sum=0;
	//�ت��a  �i�QV�㰣  �C����m l~r
	//p�i�Qv�㰣 �L�C��

int main() {
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>L[i]>>v[i]>>l[i]>>r[i];
	}
	for(int i=0;i<t;i++){
		sum=0;
		for(int y=1;y<=L[i];y++){
			if(y>=l[i]&&y<=r[i]){
				continue;
			}
			else if(y%v[i]==0){
				sum++;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}


#include<iostream>

#define ll long long
#define endl '\n'

using namespace std;

ll t,L[10005],v[10005],l[10005],r[10005],sum=0;
bool b[1000000005];
	//�ت��a  �i�QV�㰣  �C����m l~r
	//p�i�Qv�㰣 �L�C��

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>L[i]>>v[i]>>l[i]>>r[i];
	}
	for(int i=0;i<t;i++){
		if(L[i]==r[i]){
			cout<<"0"<<endl;
			return 0;
		}
		sum=0;
		for(int y=1;y<=L[i];y++){
			if(y>=l[i]&&y<=r[i]){
				continue;
			}
			else if(y%v[i]==0){
				sum++;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}


#include<iostream>

#define ll long long
#define endl '\n'

using namespace std;

ll t,L[10005],v[10005],l[10005],r[10005],sum=0;
	//�ت��a  �i�QV�㰣  �C����m l~r
	//p�i�Qv�㰣 �L�C��

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>L[i]>>v[i]>>l[i]>>r[i];
	}
	for(int i=0;i<t;i++){
		sum=0;
		for(int y=1;y<=L[i];y++){
			if(y>=l[i]&&y<=r[i]){
				continue;
			}
			else if(y%v[i]==0){
				sum++;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = 0;
		sum = a / b;
		if (d >= b)
		{
			m = c % b;
			c += m;
			sum--;
			sum -= (d - c) / b;
		}
		cout << sum << endl;
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = 0;
		sum = a / b;
		for (i = c;; i++)
		{
			if (i%b == 0)
			{
				sum--;
				break;
			}
		}
		sum -= (d - i) / b;
		cout << sum << endl;
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = 0;
		sum = a / b;
		if (c > a)
		{
			cout << sum << endl;
			continue;
		}
		if (d > a)
			d = a;
		if (d >= b)
		{
			if (c%b == 0)
				sum -= (d - c) / b, sum--;
			else
			{
				j = c / b;
				m = (j + 1)*b - c;
				c += m;
				sum--;
				sum -= (d - c) / b;
			}
		}
		cout << sum << endl;
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = 0;
		sum = a / b;
		if (c > a)
		{
			cout << sum << endl;
			continue;
		}
		if (d > a)
			d = a;
		if (d >= b)
		{
			m = c % b;
			c += m;
			sum--;
			sum -= (d - c) / b;
		}
		cout << sum << endl;
	}
	return 0;
}