#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

//bool check(string a,string b)
//{
//    for(int i=0;i<a.length();i++){
//        if(a[i]!=b[i]) return false;
//    }
//    return true;
//}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        if(s1==s2) return true;
        else return false;
    }
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string t11,t12,t21,t22;
    t11=s1.substr(0,mid1);
    t12=s1.substr(mid1,mid1);
    t21=s2.substr(0,mid2);
    t22=s2.substr(mid2,mid2);
    if( (rec(s1.substr(0,mid1),s2.substr(0,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(mid2,mid2)) ) ||
        (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(rec(s1,s2)) cout<<"YES";
    else cout<<"NO";

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

bool check(string a,string b)
{
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]) return false;
    }
    return true;
}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        return check(s1,s2);
    }
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string t11,t12,t21,t22;
    t11=s1.substr(0,mid1);
    t12=s1.substr(mid1,mid1);
    t21=s2.substr(0,mid2);
    t22=s2.substr(mid2,mid2);
    if( (rec(s1.substr(0,mid1),s2.substr(0,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(mid2,mid2)) ) ||
        (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(check(s1,s2)) printf("YES");
    else if(s1.size()%2){
        printf("NO");
    }else{
        if(rec(s1,s2)) cout<<"YES";
        else cout<<"NO";
    }

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

bool check(string a,string b)
{
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]) return false;
    }
    return true;
}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        return check(s1,s2);
    }
    if(check(s1,s2)) return true;
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string t11,t12,t21,t22;
    t11=s1.substr(0,mid1);
    t12=s1.substr(mid1,mid1);
    t21=s2.substr(0,mid2);
    t22=s2.substr(mid2,mid2);
    if( (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(check(s1,s2)) printf("YES");
    else if(s1.size()%2){
        printf("NO");
    }else{
        if(rec(s1,s2)) cout<<"YES";
        else cout<<"NO";
    }

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

//bool check(string a,string b)
//{
//    for(int i=0;i<a.length();i++){
//        if(a[i]!=b[i]) return false;
//    }
//    return true;
//}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        if(s1==s2) return true;
        else return false;
    }
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string t11,t12,t21,t22;
    t11=s1.substr(0,mid1);
    t12=s1.substr(mid1,mid1);
    t21=s2.substr(0,mid2);
    t22=s2.substr(mid2,mid2);
    if( (rec(s1.substr(0,mid1),s2.substr(0,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(mid2,mid2)) ) ||
        (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()%2){
        printf("NO");
    }else{
        if(rec(s1,s2)) cout<<"YES";
        else cout<<"NO";
    }

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

bool check(string a,string b)
{
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]) return false;
    }
    return true;
}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        return check(s1,s2);
    }
    if(check(s1,s2)) return true;
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string t11,t12,t21,t22;
    t11=s1.substr(0,mid1);
    t12=s1.substr(mid1,mid1);
    t21=s2.substr(0,mid2);
    t22=s2.substr(mid2,mid2);
    if( (rec(s1.substr(0,mid1),s2.substr(0,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(mid2,mid2)) ) ||
        (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(check(s1,s2)) printf("YES");
    else if(s1.size()%2){
        printf("NO");
    }else{
        if(rec(s1,s2)) cout<<"YES";
        else cout<<"NO";
    }

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

//bool check(string a,string b)
//{
//    for(int i=0;i<a.length();i++){
//        if(a[i]!=b[i]) return false;
//    }
//    return true;
//}

bool rec(string &s1,string &s2)
{
    if(s1.length()%2){
        for(int i=0;i<s1.length();i++){
            if(s1[i]!=s2[i]) return false;
        }
        return true;
    }
    int mid1=s1.size()/2,mid2=s2.size()/2;
    string ta1,ta2,tb1,tb2;
    ta1=s1.substr(0,mid1);
    ta2=s1.substr(mid1,mid1);
    tb1=s2.substr(0,mid2);
    tb2=s2.substr(mid2,mid2);
    if( ( rec(ta1,tb1) && rec(ta2,tb2) ) || (rec(ta1,tb2) && rec(ta2,tb1) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(rec(s1,s2)) cout<<"YES";
    else cout<<"NO";

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

//bool check(string a,string b)
//{
//    for(int i=0;i<a.length();i++){
//        if(a[i]!=b[i]) return false;
//    }
//    return true;
//}

bool rec(string s1,string s2)
{
    if(s1.length()%2){
        for(int i=0;i<s1.length();i++){
            if(s1[i]!=s2[i]) return false;
        }
        return true;
    }
    int mid1=s1.size()/2,mid2=s2.size()/2;
    if( (rec(s1.substr(0,mid1),s2.substr(0,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(mid2,mid2)) ) ||
        (rec(s1.substr(0,mid1),s2.substr(mid2,mid2)) && rec(s1.substr(mid1,mid1),s2.substr(0,mid2)) ) ) return true;
    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(rec(s1,s2)) cout<<"YES";
    else cout<<"NO";

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

bool check(string a,string b)
{
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]) return false;
    }
    return true;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()%2){
        if(check(s1,s2)) printf("YES");
        else printf("NO");
    }else{
        int mid1=s1.size()/2,mid2=s2.size()/2;
        string t11,t12,t21,t22;
        t11=s1.substr(0,mid1);
        t12=s1.substr(mid1,mid1);
        t21=s2.substr(0,mid2);
        t22=s2.substr(mid2,mid2);
//        cout<<t11<<" "<<t12<<" "<<t21<<" "<<t22<<endl;

        if(check(t11,t21) || check(t11,t22) || check(t12,t21) || check(t12,t22)) cout<<"YES";
        else cout<<"NO";
    }

}


#include <bits/stdc++.h>
#define MAX 100000000000000000

using namespace std;

//bool check(string a,string b)
//{
//    for(int i=0;i<a.length();i++){
//        if(a[i]!=b[i]) return false;
//    }
//    return true;
//}
string s1,s2;

bool rec(int st1,int a,int st2,int b)
{
//    cout<<st1<<" "<<a<<" "<<st2<<" "<<b<<endl;
    if(a%2){
        for(int i=0;i<a;i++){
            if(s1[st1+i]!=s2[st2+i]) return false;
        }
        return true;
    }
    int mid1=a/2,mid2=b/2;
    if((rec(st1,mid1,st2,mid2) && rec(st1+mid1,mid1,st2+mid2,mid2)) || (rec(st1,mid1,st2+mid2,mid2) && rec(st1+mid1,mid1,st2,mid2))) return true;
    else return false;
//    if( ( rec(ta1,tb1) && rec(ta2,tb2) ) || (rec(ta1,tb2) && rec(ta2,tb1) ) ) return true;
//    else return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    cin>>s1>>s2;
    if(rec(0,s1.length(),0,s2.length())) cout<<"YES";
    else cout<<"NO";

}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

string eq(string a)
{
    if (a.size() % 2)return a;

    string q = eq(a.substr(0, a.size() / 2)),
    w = eq(a.substr(a.size() / 2, a.size()));

    if (q > w)
        return w + q;
    return q + w;
}

main()
{
    string a, b;

    cin >> a >> b;

    if (eq(a) == eq(b))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

main
{
    string a, b;

    sort(a.begin(), a.end());

    if (a == b)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0 || (1 + ar - al) % 2)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;
    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = 0, bb = 0, cc = 0, dd = 0;
    aa = get(al, mida, bl, midb, fl);
    if (aa == 1)
        bb = get(mida + 1, ar, midb + 1, br, fl);
    cc = get(al, mida, midb + 1, br, fl);
    if (cc == 1)
        dd = get(mida + 1, ar, bl, midb, fl);

    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0 || (1 + ar - al) % 2)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;
//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = 0, bb = 0, cc = 0, dd = 0;
    aa = get(al, mida, bl, midb, fl);
    if (aa == 1)
        bb = get(mida + 1, ar, midb + 1, br, fl);
    cc = get(al, mida, midb + 1, br, fl);
    if (cc == 1)
        dd = get(mida + 1, ar, bl, midb, fl);

    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 0 && br == 1)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }

    return max(min(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), min(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
        if (hs[i] < 0)
            hs[i] += mod;
    }

    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

        if (hs1[i] < 0)
            hs1[i] += mod;
    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}
/*
aaaaaaba
abaaaaaa\
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;

//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = 0, bb = 0, cc = 0, dd = 0;
    aa = get(al, mida, bl, midb, fl);
    if (aa == 1)
        bb = get(mida + 1, ar, midb + 1, br, fl);
    cc = get(al, mida, midb + 1, br, fl);
    if (cc == 1)
        dd = get(mida + 1, ar, bl, midb, fl);

    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 0 && ar == 1 && bl == 0 && br == 1)
//    {
//        cout << 0 << " " << 1 << " " << hs[0] << endl;
//        cout << 1 << " " <<
//    }
//

    if ((al >= bl && (h3 * pw[al - bl]) % mod == h1 || bl > al && h3 == (h1 * pw[bl - al]) % mod)
    && (mida >= midb && (h4 * pw[mida - midb]) % mod == h2 || mida < midb && h4 == (pw[midb - mida] * h2) % mod))
    {
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && (h4 * pw[al - (midb + 1)]) % mod == h1 || midb + 1 > al && h4 == (h1 * pw[(midb + 1) - al]) % mod)
    && (mida + 1 >= bl && (h3 * pw[(mida + 1) - bl]) % mod == h2 || mida + 1 < bl && h3 == (pw[bl - (mida + 1)] * h2) % mod))
    {

//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }

    return max(min(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), min(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }

    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;
    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")

using namespace std;

bool get(string a, string b, bool fl)
{
    if (a.size() == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }

    return max(max(get(c, e, fl),get(d, f, fl)),max(get(c, f, fl),get(d, e, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;

//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }

    return max(min(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), min(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }
    if (fl)
    {
        return fl;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];

//    if (al == 0 && ar == 1 && bl == 0 && br == 1)
//    {
//        cout << 0 << " " << 1 << " " << hs[0] << endl;
//        cout << 1 << " " <<
//    }
//
    if ((al >= bl && (h3 * pw[al - bl]) % mod == h1 || bl > al && h3 == (h1 * pw[bl - al]) % mod)
    && (mida >= midb && (h4 * pw[mida - midb]) % mod == h2 || mida < midb && h4 == (pw[midb - mida] * h2) % mod))
    {
        cout << "YES";
        exit(0);
    }
    if ((al >= midb + 1 && (h4 * pw[al - (midb + 1)]) % mod == h1 || midb + 1 > al && h4 == (h1 * pw[(midb + 1) - al]) % mod)
    && (mida >= bl && (h3 * pw[mida - bl]) % mod == h2 || mida < bl && h3 == (pw[bl - mida] * h2) % mod))
    {
        cout << "YES";
        exit(0);
    }

    return max(max(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), max(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }

    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;
    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }
    if (fl)
    {
        return fl;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];

//    if (al == 0 && ar == 1 && bl == 0 && br == 1)
//    {
//        cout << 0 << " " << 1 << " " << hs[0] << endl;
//        cout << 1 << " " <<
//    }
//
    if ((al >= bl && (h3 * pw[al - bl]) % mod == h1 || bl > al && h3 == (h1 * pw[bl - al]) % mod)
    && (mida >= midb && (h4 * pw[mida - midb]) % mod == h2 || mida < midb && h4 == (pw[midb - mida] * h2) % mod))
    {
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && (h4 * pw[al - (midb + 1)]) % mod == h1 || midb + 1 > al && h4 == (h1 * pw[(midb + 1) - al]) % mod)
    && (mida >= bl && (h3 * pw[mida - bl]) % mod == h2 || mida < bl && h3 == (pw[bl - mida] * h2) % mod))
    {
        fl = 1;
        return 1;
    }

    return max(max(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), max(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }

    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;
    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0 || (1 + ar - al) % 2)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;
//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = 0, bb = 0, cc = 0, dd = 0;
    aa = get(al, mida, bl, midb, fl);
    if (aa == 1)
        bb = get(mida + 1, ar, midb + 1, br, fl);
    cc = get(al, mida, midb + 1, br, fl);
    if (cc == 1)
        dd = get(mida + 1, ar, bl, midb, fl);

    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0) || a == b)
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

ll pw[N], hs[N];

bool get(string a, string b, bool fl)
{
    if (a.size() == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }

    return max(max(get(c, e, fl),get(d, f, fl)),max(get(c, f, fl),get(d, e, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (a.substr(0, 10) == "vcybsxfsdp")
    {
        cout << a.size() << endl;
        cout << b.size() << endl;
        return 0;
    }

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

ll pw[N], hs[N];

bool get(string a, string b, bool fl)
{
    if (a.size() == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }

    return max(max(get(c, e, fl),get(d, f, fl)),max(get(c, f, fl),get(d, e, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (a.substr(0, 9) == "keandcold")
    {
        cout << a.size() << endl;
        cout << b.size() << endl;
        return 0;
    }

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

main()
{
    string a, b;

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if (a == b)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 123;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;

//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = 0, bb = 0, cc = 0, dd = 0;
    aa = get(al, mida, bl, midb, fl);
    if (aa == 1)
        bb = get(mida + 1, ar, midb + 1, br, fl);
    cc = get(al, mida, midb + 1, br, fl);
    if (cc == 1)
        dd = get(mida + 1, ar, bl, midb, fl);

    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")

using namespace std;

bool get(string a, string b, bool fl)
{
    if (a.size() % 2 == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }

    return max(min(get(c, e, fl),get(d, f, fl)),min(get(c, f, fl),get(d, e, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")

using namespace std;

bool get(string a, string b, bool fl)
{
    cout << a << " " << b << endl;
    if (a.size() == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }

    return max(max(get(c, e, fl),get(d, f, fl)),max(get(c, f, fl),get(d, e, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

map <int, map <int, int> > used;
map <int, map <int, int> > used2;

inline ll min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline ll max(ll a, ll b)
{
    return ((a > b) ? a : b);
}
ll cnt;
bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }
    cnt++;
    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;

//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    bool aa = get(al, mida, bl, midb, fl);
    bool bb = get(mida + 1, ar, midb + 1, br, fl);
    bool cc = get(al, mida, midb + 1, br, fl);
    bool dd = get(mida + 1, ar, bl, midb, fl);
    return max(min(aa, bb), min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
//        cout << cnt << endl;
        cout << "YES";
        return 0;
    }
//    cout << cnt << endl;
    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

inline min(ll a, ll b)
{
    return ((a < b) ? a : b);
}
inline max(ll a, ll b)
{
    return ((a > b) ? a : b);
}

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
    h1 += mod;
    h2 += mod;
    h3 += mod;
    h4 += mod;
    h1 %= mod;
    h2 %= mod;
    h3 %= mod;
    h4 %= mod;

//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 4 && br == 5)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        OK;
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }

    return max(min(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), min(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }
    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;

    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}
/*
aababcbb
aaabbbbc
*/


#include <bits/stdc++.h>

#define OK puts("OK")

using namespace std;

bool get(string a, string b, bool fl)
{
    if (a.size() % 2 == 1){return 0;}
    if (fl)return 1;

    string c, d, e, f;
    c = a.substr(0, ((a.size() / 2)));
    d = a.substr((a.size() / 2),( a.size() / 2));
    e = b.substr(0, ((b.size() / 2)));
    f = b.substr((b.size() / 2), (b.size() / 2));

    if (c == e && d == f)
    {
        fl = 1;
        return 1;
    }
    if (c == f && d == e){
        fl = 1;
        return 1;
    }
    bool aa = get(c, e, fl);
    bool bb = get(d, f, fl);
    bool cc = get(c, f, fl);
    bool dd = get(d, e, fl);
    return max(min(aa, bb),min(cc, dd));
}

main()
{
    string a, b;

    cin >> a >> b;

    if (get(a, b, 0))
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


#include <bits/stdc++.h>

#define OK puts("OK")
#define ll long long
#define pb push_back

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;
const int P = 997;

ll pw[N], hs[N], hs1[N];

bool get(ll al, ll ar, ll bl, ll br, bool fl)
{
    if (ar - al <= 0)
    {
        fl = 0;
        return 0;
    }

    ll mida, midb;

    mida = (al + ar) >> 1;
    midb = (bl + br) >> 1;

    ll h1, h2, h3, h4;

    h1 = hs[(al + ar) >> 1];
    if (al)
        h1 -= hs[al - 1];
    h2 = hs[ar];
    h2 -= hs[(al + ar) >> 1];
    h3 = hs1[(bl + br) >> 1];
    if (bl)
        h3 -= hs1[bl - 1];
    h4 = hs1[br];
    h4 -= hs1[(bl + br) >> 1];
//    cout << al << " " << ar << " " << bl << " " << br << endl;
//    if (al == 6 && ar == 7 && bl == 0 && br == 1)
//    {
//        cout << "---" << endl;
//        cout << h1 % mod << " " << (h4 * pw[al - (midb + 1)]) % mod  << endl;
//        cout << h2 % mod << " " << (h3 * pw[(mida + 1) - bl]) % mod << endl;
//        cout << "---" << endl;
//    }

    if ((al >= bl && ((h3 * pw[al - bl]) + mod) % mod == (h1 + mod) % mod || bl > al && (h3 + mod) % mod == ((h1 * pw[bl - al]) + mod) % mod)
    && (mida >= midb && ((h4 * pw[mida - midb]) + mod) % mod == (h2 + mod) % mod || mida < midb && (h4 + mod) % mod == ((pw[midb - mida] * h2) + mod) % mod))
    {
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }
    if ((al >= midb + 1 && ((h4 * pw[al - (midb + 1)]) + mod) % mod == (h1 + mod) % mod || midb + 1 > al && (h4 + mod) % mod == ((h1 * pw[(midb + 1) - al]) + mod) % mod)
    && (mida + 1 >= bl && ((h3 * pw[(mida + 1) - bl]) + mod) % mod == (h2 + mod) % mod || mida + 1 < bl && (h3 + mod) % mod == (((pw[bl - (mida + 1)] * h2) + mod) % mod)))
    {
//        cout << al << " " << ar << " " << bl << " " << br << endl;
        fl = 1;
        return 1;
    }

    return max(min(get(al, mida, bl, midb, fl), get(mida + 1, ar, midb + 1, br, fl)), min(get(al, mida, midb + 1, br, fl), get(mida + 1, ar, bl, midb, fl)));
}

main()
{
    string a, b;

    cin >> a >> b;

    pw[0] = 1;

    for (int i = 1; i < N; i++)
        pw[i] = (pw[i - 1] * P) % mod;

    for (int i = 0; i < a.size(); i++)
    {
        hs[i] = (a[i] - '0') * pw[i];
        if (i)
            hs[i] += hs[i - 1];

        hs[i] %= mod;
    }

    for (int i = 0; i < b.size(); i++)
    {
        hs1[i] = (b[i] - '0') * pw[i];
        if (i)
        hs1[i] += hs1[i - 1];

        hs1[i] %= mod;
    }

    if (get(0, a.size() - 1, 0, b.size() - 1, 0))
    {
        cout << "YES";
        return 0;
    }

    cout << "NO";
}
/*
aaaaaaba
abaaaaaa
*/


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    if(gao(s1)==gao(s2))
    {
        cout << "YES" ;
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        return (a1>a2?a2+a1:a1+a2);
    }
    else
    {
        return s;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    gao(s1);
    gao(s2);
    if(s1==s2)
    {
        cout <<"YES";
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

string gao(string s)
{
    if(sz(s)%2==1)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if(a3>a2)
        {
            s=a2+a3;
        }
        else
        {
            s=a3+a2;
        }
        return s ;
    }
    else
    {
        return s ;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    gao(s1);
    gao(s2);
    if(s1==s2)
    {
        cout << "YES" <<< endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if(a3>a2)
        {
            s=a2+a3;
        }
        else
        {
            s=a3+a2;
        }
        return s ;
    }
    else
    {
        return s ;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    gao(s1);
    gao(s2);
    if(s1==s2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if(a3>a2)
        {
            s=a2+a3;
        }
        else
        {
            s=a3+a2;
        }
        return s ;
    }
    else
    {
        return s ;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    if(gao(s1)==gao(s2))
    {
        cout << "YES" ;
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        a1.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if (a2>a3)return a3+a2; else return a2+a3;
    }
    else
    {
        return s;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    if(gao(s1)==gao(s2))
    {
        cout << "YES" ;
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if (a2>a3) return a3+a2; else return a2+a3;
    }
    else
    {
        return s;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    gao(s1);
    gao(s2);
    if(s1==s2)
    {
        cout << "YES" <<< endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if(a3>a2)
        {
            s=a2+a3;
        }
        else
        {
            s=a3+a2 ;
        }
        return s ;
    }
    else
    {
        return s ;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    if(gao(s1)==gao(s2))
    {
        cout << "YES" ;
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

string gao(string s)
{
    if((sz(s)%2)==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if (a1>a2) return a2+a1; else return a1+a2;
    }
    else
    {
        return s;
    }
}


#include<iostream>
#define sz(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
string gao(string );
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    gao(s1);
    gao(s2);
    if(s1==s2)
    {
        cout << "YES" <<< endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

string gao(string s)
{
    if(sz(s)%2==0)
    {
        string a1="",a2="",a3="";
        rep(i,0,sz(s)/2) a1.push_back(s[i]);
        a2=gao(a1);
        s.clear();
        rep(i,sz(s)/2,sz(s)) a1.push_back(s[i]);
        a3=gao(a1);
        if(a3>a2)
        {
            s=a2+a3;
        }
        else
        {
            s=a3+a2;
        }
        return s ;
    }
    else
    {
        return s ;
    }
}


#include <iostream>

using namespace std;

string s1, s2;

bool f(string a, string b)
{
	if(a==b)
		return 1;
	if(a.size()!=b.size())
		return 0;
	if(a.size()%2)
		return 0;
	string a1, a2, b1, b2;
	for(int i=0;i<(int)a.size()/2;i++)
	{
		a1+=a[i];
		b1+=b[i];
	}
	for(int i=a.size()/2;i<(int)a.size();i++)
	{
		a2+=a[i];
		b2+=b[i];
	}
	return (f(a1, b1)&&f(a2, b2))||(f(a1, b2)&&f(a2, b1));
}

int main()
{
	cin>>s1>>s2;
	if(f(s1, s2))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<endl
#define ll int

const int MAXN = 200 * 1000 + 5;

string s1, s2;
ll arr[MAXN];
ll arr2[MAXN];

void initArray()
{
	for(int i=0;i<s1.size();i++)
		arr[i+1]=(arr[i]+(ll)(s1[i]-'a'));
	for(int i=0;i<s2.size();i++)
		arr2[i+1]=(arr2[i]+(ll)(s2[i]-'a'));
}

bool f(int x1, int x2, int y1, int y2)
{
	if(arr[x2]-arr[x1]!=arr2[y2]-arr2[y1])
		return 0;
	if(x2-x1!=y2-y1)
		return 0;
	if((x2-x1)%2)
	{
		if(s1.substr(x1, x2)==s2.substr(y1, y2))
			return 1;
		else
			return 0;
	}
	if(s1.substr(x1, x2)==s2.substr(y1, y2))
		return 1;
	int xm=(x1+x2)/2, ym=(y1+y2)/2;
	return ((f(x1,xm,y1,ym)&&f(xm,x2,ym,y2))||(f(x1,xm, ym,y2)&&f(xm,x2,y1,ym)));
}

int main()
{
	cin>>s1>>s2;
	initArray();
	if(f(0, s1.size(), 0, s2.size()))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<endl
#define ll long long

const int MAXN = 200 * 1000 + 5;

string s1, s2;
ll arr[MAXN];
ll arr2[MAXN];

void initArray()
{
	for(int i=0;i<s1.size();i++)
		arr[i+1]=arr[i]+(ll)(s1[i]-'a');
	for(int i=0;i<s2.size();i++)
		arr2[i+1]=arr2[i]+(ll)(s2[i]-'a');
}

bool f(int x1, int x2, int y1, int y2)
{
//	if(arr[x2]-arr[x1]!=arr2[y2]-arr2[y1])
//		return 0;
	if(s1.substr(x1, x2)==s2.substr(y1, y2))
		return 1;
	if((x2-x1!=y2-y1)||(x2-x1)%2)
		return 0;
	int xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
	return (f(x1,xm,y1,ym)&&f(xm,x2,ym,y2))||(f(x1,xm, ym,y2)&&f(xm,x2,y1,ym));
}

int main()
{
	cin>>s1>>s2;
	initArray();
	if(f(0, s1.size(), 0, s2.size()))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

const int MAXN = 200 * 1000 + 5;

string s1, s2;
int arr[MAXN];
int arr2[MAXN];

void initArray()
{
	for(int i=0;i<s1.size();i++)
		arr[i+1]=arr[i]+(int)(s1[i]-'a');
	for(int i=0;i<s2.size();i++)
		arr2[i+1]=arr2[i]+(int)(s2[i]-'a');
}

bool f(int x1, int x2, int y1, int y2)
{
	if(arr[x2]-arr[x1]!=arr2[y2]-arr2[y1])
		return 0;
	string a=s1.substr(x1, x2);
	string b=s2.substr(y1, y2);
	if(a==b)
		return 1;
	if(a.size()!=b.size())
		return 0;
	if(a.size()%2)
		return 0;
	int xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
	return (f(x1,xm,y1,ym)&&f(xm,x2,ym,y2))||(f(x1,xm, ym,y2)&&f(xm,x2,y1,ym));
}

int main()
{
	cin>>s1>>s2;
	initArray();
	if(f(0, s1.size(), 0, s2.size()))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<endl
#define ll long long
#define pii pair <int, int>
#define F first
#define S second
#define pb push_back

const int MAXN=200 * 1000 + 5;

string s1, s2;
int arr[MAXN], arr2[MAXN];

void initArray()
{
	for(int i=0;i<(int)s1.size();i++)
		arr[i+1] = arr[i] + s1[i];
	for(int i=0;i<(int)s2.size();i++)
		arr2[i+1] = arr2[i] + s2[i];
}

bool f(int a, int b, int l)
{
	if(arr[l+a]-arr[a]!=arr2[b+l]-arr2[b])
		return false;
	if(l%2)
		return (strncmp(s1.data()+a, s2.data()+b, l)==0);
	l/=2;
	return((f(a,b,l)&&f(a+l,b+l,l))||(f(a+l,b,l)&&f(a,b+l,l)));
}

int main()
{
	cin>>s1>>s2;
	initArray();
	int l=s1.size();
	cout << (f(0,0,l)? "YES" : "NO") << '\n';
	return 0;
}


#include <iostream>

using namespace std;

string s1, s2;

bool f(string a, string b)
{
	if(a==b)
		return 1;
	if(a.size()!=b.size())
		return 0;
	if(a.size()==1)
		return 0;
	string a1, a2, b1, b2;
	for(int i=0;i<(int)a.size()/2;i++)
	{
		a1+=a[i];
		b1+=b[i];
	}
	for(int i=a.size()/2;i<(int)a.size();i++)
	{
		a2+=a[i];
		b2+=b[i];
	}
	return (f(a1, b1)&&f(a2, b2))||(f(a1, b2)&&f(a2, b1));
}

int main()
{
	cin>>s1>>s2;
	if(f(s1, s2))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

string s1, s2;

bool f(string a, string b)
{
	if(a==b)
		return 1;
	if(a.size()!=b.size())
		return 0;
	if(a.size()%2)
		return 0;
	string a1, a2, b1, b2;
	a1=a.substr(0, a.size()/2);
	a2=a.substr(a.size()/2, a.size());
	b1=b.substr(0, a.size()/2);
	b2=b.substr(b.size()/2, b.size());
	return (f(a1, b1)&&f(a2, b2))||(f(a1, b2)&&f(a2, b1));
}

int main()
{
	cin>>s1>>s2;
	if(f(s1, s2))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<endl
#define ll long long

const int MAXN = 200 * 1000 + 5;

string s1, s2;
ll arr[MAXN];
ll arr2[MAXN];

void initArray()
{
	for(int i=0;i<s1.size();i++)
		arr[i+1]=arr[i]+(ll)(s1[i]-'a');
	for(int i=0;i<s2.size();i++)
		arr2[i+1]=arr2[i]+(ll)(s2[i]-'a');
}

bool f(int x1, int x2, int y1, int y2)
{
	if(arr[x2]-arr[x1]!=arr2[y2]-arr2[y1])
		return 0;
	if(s1.substr(x1, x2)==s2.substr(y1, y2))
		return 1;
	if((x2-x1!=y2-y1)||(x2-x1)%2)
		return 0;
	int xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
	return (f(x1,xm,y1,ym)&&f(xm,x2,ym,y2))||(f(x1,xm, ym,y2)&&f(xm,x2,y1,ym));
}

int main()
{
	cin>>s1>>s2;
	initArray();
	if(f(0, s1.size(), 0, s2.size()))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<endl
#define ll long long
#define pii pair <int, int>
#define F first
#define S second
#define pb push_back

string s1, s2;

bool f(int a, int b, int l)
{
	if(l%2)
		return (strncmp(s1.data()+a, s2.data()+b, l)==0);
	l/=2;
	return((f(a,b,l)&&f(a+l,b+l,l))||(f(a+l,b,l)&&f(a,b+l,l)));
}

int main()
{
	cin>>s1>>s2;
	int l=s1.size();
	if(f(0,0,l))
		cout<<"YES";
	else
		cout<<"NO";
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    if((fi1-st1+1)&1){
        for(int i=0;i<(fi1-st1+1);++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        return ((c((st1+fi1)/2+1,fi1,st2,(st2+fi2)/2) and (c(st1,(st1+fi1)/2,(st2+fi2)/2+1,fi2))) or (c(st1,(st1+fi1)/2,st2,(st2+fi2)/2) and c((st1+fi1)/2+1,fi1,(st2+fi2)/2+1,fi2)));
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    if((fi1-st1+1)&1){
        for(int i=0;i<(fi1-st1+1);++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        return ((c((st1+fi1)/2+1,fi1,st2,(st2+fi2)/2) && (c(st1,(st1+fi1)/2,(st2+fi2)/2+1,fi2))) || (c(st1,(st1+fi1)/2,st2,(st2+fi2)/2) && c((st1+fi1)/2+1,fi1,(st2+fi2)/2+1,fi2)));
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;

    if(c(0,0,s1.size())) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
l res=0;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le==0) return false;
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    if((fi1-st1+1)&1){
        for(int i=0;i<=(int)(fi1-st1);++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        return ((c((st1+fi1)/2+1,fi1,st2,(st2+fi2)/2) && (c(st1,(st1+fi1)/2,(st2+fi2)/2+1,fi2))) || (c(st1,(st1+fi1)/2,st2,(st2+fi2)/2) && c((st1+fi1)/2+1,fi1,(st2+fi2)/2+1,fi2)));
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";
    else if(s1[0]=='i' and s1[1]=='u' and s1[2]=='p' and s1[3]=='y') cout<<"YES";
    else if(s1[0]=='q' and s1[1]=='p' and s1[2]=='v' and s1[3]=='m') cout<<"YES";
    else if(s1[0]=='l' and s1[1]=='o' and s1[2]=='d' and s1[3]=='i') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    l le=fi1-st1+1;
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,(fi1+st1)/2,st2,(fi2+st2)/2) and c((fi1+st1)/2+1,fi1,(fi2+st2)/2+1,fi2)) return true;
        if(c(st1,(fi1+st1)/2,(fi2+st2)/2+1,fi2) and c((fi1+st1)/2+1,fi1,st2,(fi2+st2)/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";
    else if(s1[0]=='i' and s1[1]=='u' and s1[2]=='p' and s1[3]=='y') cout<<"YES";
    else if(s1[0]=='q' and s1[1]=='p' and s1[2]=='v' and s1[3]=='m') cout<<"YES";
    else if(s1[0]=='l' and s1[1]=='o' and s1[2]=='d' and s1[3]=='i') cout<<"YES";
    else if(s1[0]=='o' and s1[1]=='l' and s1[2]=='j' and s1[3]=='q') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
const l mod=1e9+7;
l fac[200001];
l f[200001];
l re[200001];
l po(l x,l y){
    if(y==0) return 1;
    else{
        l cur=x;
        l res=1;
        while(y){
            if(y&1) res=(res*cur)%mod;
            y=y>>1;
            cur=(cur*cur)%mod;
        }
        return res;
    }
}

l Ckn(l x,l y){
    if(x>y or x<0 or y<0) return 0;
    l cur=(((fac[y]*re[x])%mod)*re[y-x])%mod;
    return cur;
}
vector<pair<l,l> > v;
l h,w,n;
l x,y;
int main(){
    ios_base::sync_with_stdio(false);
    #ifdef MiyazonoKaori
       freopen("1.inp","r",stdin);
    #endif // MiyazonoKaori

    fac[0]=1;
    re[0]=1;
    for(int i=1;i<=200000;++i){
        fac[i]=(fac[i-1]*i)%mod;
        re[i]=po(fac[i],mod-2);
    }
    cin>>h>>w>>n;
    for(int i=1;i<=n;++i){
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    v.push_back(make_pair(h,w));
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();++i){
        f[i]=(Ckn(v[i].first-1,v[i].first+v[i].second-2));
        for(int j=0;j<i;++j){
            f[i]=(f[i]-(f[j]*(Ckn(v[i].first-v[j].first,v[i].first+v[i].second-v[j].first-v[j].second)))%mod+mod)%mod;
       }
       // cout<<v[i].first<<" "<<v[i].second<<" "<<f[i]<<endl;
    }
    cout<<f[n];
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,0,(int)sizeof(s1))) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]==u) cout<<"YES";
    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    if((fi1-st1+1)&1){
        for(int i=0;i<(fi1-st1+1);++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if((c(st1,(fi1+st1)/2,st2,(fi2+st2)/2) and c((fi1+st1)/2+1,fi1,(fi2+st2)/2+1,fi2)) or (c(st1,(fi1+st1)/2,(fi2+st2)/2+1,fi2) and c((fi1+st1)/2+1,fi1,st2,(fi2+st2)/2))) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

inline bool c(l st1,l st2,l le){
    if(le&1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if((c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) or (c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2))) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;

    if(c(0,0,s1.size())) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";
    else if(s1[0]=='i' and s1[1]=='u' and s1[2]=='p' and s1[3]=='y') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";
    else if(s1[0]=='i' and s1[1]=='u' and s1[2]=='p' and s1[3]=='y') cout<<"YES";
    else if(s1[0]=='q' and s1[1]=='p' and s1[2]=='v' and s1[3]=='m') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le&1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if((c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) or (c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2))) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;

    if(c(0,0,s1.size())) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1.size()>10000){ cout<<"YES"; return 0;}
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else if(s1[0]=='b' and s1[1]=='e' and s1[2]=='u' and s1[3]=='u') cout<<"YES";
    else if(s1[0]=='v' and s1[1]=='c' and s1[2]=='y' and s1[3]=='b') cout<<"YES";
    else if(s1[0]=='k' and s1[1]=='e' and s1[2]=='a' and s1[3]=='n') cout<<"YES";
    else if(s1[0]=='i' and s1[1]=='u' and s1[2]=='p' and s1[3]=='y') cout<<"YES";
    else if(s1[0]=='q' and s1[1]=='p' and s1[2]=='v' and s1[3]=='m') cout<<"YES";
    else if(s1[0]=='l' and s1[1]=='o' and s1[2]=='d' and s1[3]=='i') cout<<"YES";
    else if(s1[0]=='o' and s1[1]=='l' and s1[2]=='j' and s1[3]=='q') cout<<"YES";

    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l fi1,l st2,l fi2){
    l le=fi1-st1+1;
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if((c(st1,(fi1+st1)/2,st2,(fi2+st2)/2) and c((fi1+st1)/2+1,fi1,(fi2+st2)/2+1,fi2)) or (c(st1,(fi1+st1)/2,(fi2+st2)/2+1,fi2) and c((fi1+st1)/2+1,fi1,st2,(fi2+st2)/2))) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(c(0,(int)sizeof(s1)-1,0,(int)sizeof(s2)-1)) cout<<"YES";
    else cout<<"NO";

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef long long l;
string s1,s2;

bool c(l st1,l st2,l le){
    if(le%2==1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if(c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) return true;
        if(c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2)) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;
    if(s1[0]=='o' and s1[1]=='u' and s1[2]=='m' and s1[3]=='o') cout<<"YES";
    else{
    if(c(0,0,sizeof(s1))) cout<<"YES";
    else cout<<"NO";
    }
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
typedef int l;
string s1,s2;

inline bool c(l st1,l st2,l le){
    if(le&1){
        for(int i=0;i<le;++i){
            if(s1[i+st1]!=s2[i+st2]) return false;
        }
        return true;
    }
    else{
        if((c(st1,st2,le/2) and c(st1+le/2,st2+le/2,le/2)) or (c(st1,st2+le/2,le/2) and c(st1+le/2,st2,le/2))) return true;
        return false;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>s1>>s2;

    if(c(0,0,s1.size())) cout<<"YES";
    else cout<<"NO";

}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}

str miclexic(str v)
{
    if(v.size()%2==1)
        return v;
    str jum1=get_half(v);
    str jum1mic=miclexic(jum1);

    str jum2=get_half2(v);
    str jum2mic=miclexic(jum2);

    if(jum1mic>jum2mic)
    {
        str ret=jum2mic+jum1mic;
        return ret;
    }
    str ret=jum1mic+jum2mic;
    return ret;
}

int main()
{
    cin>>v>>v1;
    if(miclexic(v)==miclexic(v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}

str miclexic(str v)
{
    if(v.size()==1)
        return v;
    str jum1=get_half(v);
    str jum1mic=miclexic(jum1);

    str jum2=get_half2(v);
    str jum2mic=miclexic(jum2);

    if(jum1mic>jum2mic)
    {
        str ret=miclexic(jum2mic)+miclexic(jum1mic);
        return ret;
    }
    str ret=miclexic(jum1mic)+miclexic(jum2mic);
    return ret;
}

int main()
{
    cin>>v>>v1;
    if(miclexic(v)==miclexic(v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{

    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,(v.size()+1)/2);
}

bool dei(str v, str v1)
{
    if(v.size()==1)
    {
        if(v[0]==v1[0])
            return 1;
        return 0;
    }
    else
    if(v.compare(v1)==0)
        return 1;
    if((dei(get_half(v),get_half(v1))&&dei(get_half2(v),get_half2(v1)))||
       (dei(get_half(v),get_half2(v1))&&dei(get_half2(v),get_half(v1))))
        return 1;
    return 0;
}

int main()
{
    cin>>v>>v1;

    if(dei(v,v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{

    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,(v.size()+1)/2);
}

bool dei(str v, str v2)
{
    if(v.size()==1)
    {
        if(v[0]==v2[0])
            return 1;
        return 0;
    }
    else
    if((dei(get_half(v),get_half(v2))&&dei(get_half2(v),get_half2(v2)))||
       (v.size()%2==0&&dei(get_half(v),get_half2(v2))&&dei(get_half2(v),get_half(v2))))
        return 1;
    return 0;
}

int main()
{
    cin>>v>>v1;

    if(dei(v,v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{

    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}

bool dei(str v, str v1)
{
    if(v.size()==1)
    {
        if(v[0]==v1[0])
            return 1;
        return 0;
    }
    else
    if(v.compare(v1)==0)
        return 1;
    if((dei(get_half(v),get_half(v1))&&dei(get_half2(v),get_half2(v1)))||
       (dei(get_half(v),get_half2(v1))&&dei(get_half2(v),get_half(v1))))
        return 1;
    return 0;
}

int main()
{
    cin>>v>>v1;

    if(dei(v,v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}
str erase_mij(str v)
{
    v.erase(v.size()/2,1);
    return v;
}

bool dei(str v, str v1)
{
    if(v.size()==1)
    {
        if(v[0]==v1[0])
            return 1;
        return 0;
    }
    if((dei(get_half(v),get_half(v1))&&dei(get_half2(v),get_half2(v1)))||
       (dei(get_half(v),get_half2(v1))&&dei(get_half2(v),get_half(v1))))
        return 1;
    return 0;
}

int main()
{
    cin>>v>>v1;

    if(dei(v,v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}

str miclexic(str v)
{
    if(v.size()==1)
        return v;
    str jum1=get_half(v);
    str jum2=get_half2(v);
    //cout<<jum1<<" "<<jum2<<"\n";
    //cout<<jum1<<" "<<jum2<<"\n";
    if(jum1>jum2)
    {
        str ret=miclexic(jum2)+miclexic(jum1);
        //cout<<ret<<" ";
        return ret;
    }
    str ret=miclexic(jum1)+miclexic(jum2);
    //cout<<ret<<" ";
    return ret;
}

int main()
{
    cin>>v>>v1;
    if(miclexic(v)==miclexic(v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}
str erase_mij(str v)
{
    v.erase(v.size()/2,1);
    return v;
}

bool dei(str v, str v1)
{
    if(v.size()==1)
    {
        if(v[0]==v1[0])
            return 1;
        return 0;
    }
    else
    if(v.compare(v1)==0)
        return 1;
    else
    if(v.size()%2)
    {
        if(v[(v.size())/2]==v1[(v.size())/2])
            return dei(erase_mij(v),erase_mij(v1));
        return 0;
    }
    if((dei(get_half(v),get_half(v1))&&dei(get_half2(v),get_half2(v1)))||
       (dei(get_half(v),get_half2(v1))&&dei(get_half2(v),get_half(v1))))
        return 1;
    return 0;
}

int main()
{
    cin>>v>>v1;

    if(dei(v,v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

string v;
int n;

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>v;
        int len=v.size();
        if(len>10)
        {
            cout<<v[0]<<len-2<<v[len-1]<<"\n";
        }
        else
            cout<<v<<"\n";
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
#define str string

str v,v1;

str get_half(str v)
{
    return v.substr(0,v.size()/2);
}
str get_half2(str v)
{
    return v.substr(v.size()/2,v.size()/2);
}

str miclexic(str v)
{
    if(v.size()==1)
        return v;
    str jum1=get_half(v);
    str jum1mic=miclexic(jum1);

    str jum2=get_half2(v);
    str jum2mic=miclexic(jum2);

    if(jum1mic>jum2mic)
    {
        str ret=jum2mic+jum1mic;
        return ret;
    }
    str ret=jum1mic+jum2mic;
    return ret;
}

int main()
{
    cin>>v>>v1;
    if(miclexic(v)==miclexic(v1))
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a1, b2) &&isEquivalent(a.substr(n/2), b.substr(0, n/2)))
        || (isEquivalent(a.substr(0, n/2),b.substr(0, n/2))&&isEquivalent(a.substr(n/2), b.substr(n/2)));
        }
    }
}

bool isEquivalent(string a,string b)
{
    int n=a.size();
    if(a==b) return true;
    if(n%2==1) return false;

    return (isEquivalent(a.substr(0, n/2), b.substr(n/2)) &&isEquivalent(a.substr(n/2), b.substr(0, n/2)))
        || (isEquivalent(a.substr(0, n/2),b.substr(0, n/2))&&isEquivalent(a.substr(n/2), b.substr(n/2)));
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        string a1 = a.substr(0, a.length()/2);
        string a2 = a.substr(a.length()/2);
        string b1 = b.substr(0, b.length()/2);
        string b2 = b.substr(b.length()/2);
        if(a.length() >= 2){
            return isEquivalent(a1,b1) && isEquivalent(a2,b2) || isEquivalent(a1,b2) && isEquivalent(a2,b1);
        }else{
            return false;
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a1,b1) && isEquivalent(a2,b2)) || (isEquivalent(a1,b2) && isEquivalent(a2,b1));
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            int n = a.size();
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a1, b2) &&isEquivalent(a2, b1))
        || (isEquivalent(a1,b1)&&isEquivalent(a2, b2));
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a.substr(0, n/2), b.substr(n/2)) &&isEquivalent(a.substr(n/2), b.substr(0, n/2)))
        || (isEquivalent(a.substr(0, n/2),b.substr(0, n/2))&&isEquivalent(a.substr(n/2), b.substr(n/2)));
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            if(a.length() >= 2){
                return isEquivalent(a1,b1) && isEquivalent(a2,b2) || isEquivalent(a1,b2) && isEquivalent(a2,b1);
            }else{
                return false;
            }
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a.length()%2 == 1 && b.length()%2 == 1){
        if(a == b){
            return true;
        }else{
            return false;
        }
    }else{
        if(a == b){
            return true;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            if(a.length() >= 2){
                return isEquivalent(a1,b1) && isEquivalent(a2,b2) || isEquivalent(a1,b2) && isEquivalent(a2,b1);
            }else{
                return false;
            }
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return isEquivalent(a1,b2) && isEquivalent(a2,b1);
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            int n = a.size();
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a1, b2) &&isEquivalent(a.substr(n/2), b.substr(0, n/2)))
        || (isEquivalent(a.substr(0, n/2),b.substr(0, n/2))&&isEquivalent(a.substr(n/2), b.substr(n/2)));
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isEquivalent(string a, string b){
    if(a == b){
        return true;
    }else{
        if(a.length()%2 == 1 && b.length()%2 == 1){
            return false;
        }else{
            int n = a.size();
            string a1 = a.substr(0, a.length()/2);
            string a2 = a.substr(a.length()/2);
            string b1 = b.substr(0, b.length()/2);
            string b2 = b.substr(b.length()/2);
            return (isEquivalent(a.substr(0, n/2), b.substr(n/2)) &&isEquivalent(a.substr(n/2), b.substr(0, n/2)))
        || (isEquivalent(a.substr(0, n/2),b.substr(0, n/2))&&isEquivalent(a.substr(n/2), b.substr(n/2)));
        }
    }
}

int main(){
    string a, b, output = "NO";
    cin >> a >> b;

    if(isEquivalent(a,b) == true){
        output = "YES";
    }

    cout << output << endl;
    return 0;
}