#include <bits/stdc++.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 400010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
struct info
{
    int tup[2], indx; //tup[0] = prev rank, tup[1] = new rank
}arr[MAX];

int n, sorted[20][MAX], step;
char text[MAX];

bool comp(const info &a, const info &b)
{
    return a.tup[0] != b.tup[0]? a.tup[0] < b.tup[0] : a.tup[1] < b.tup[1];
}

void build_suffix_array(void)
{
    int i, jump;
    for(i = 0; i < n; i++)
    {
        sorted[0][i] = text[i] - 'a'; //rank suffixes according to 1st char
//        clr(arr[i].tup, 0);
    }
    for(step = 1, jump = 1; jump <= n; step++, jump <<= 1)
    {
        for(i = 0; i <=n; i++)
        {
            arr[i].indx = i;
            arr[i].tup[0] = sorted[step - 1][i]; // what i was in prev step
            arr[i].tup[1] = i + jump < n? sorted[step - 1][i + jump] : -1;
        }
        sort(arr, arr + n, comp);
        sorted[step][arr[0].indx] = 0;
        for(i = 1; i < n; i++)
            sorted[step][arr[i].indx] = arr[i].tup[0] == arr[i - 1].tup[0] &&
            arr[i].tup[1] == arr[i - 1].tup[1] ? sorted[step][arr[i - 1].indx] : i;
    }
//    cout << "Suffix Array : \n\n";
//    for(i = 0; i < n; i++)
//        cout<<arr[i].indx<<' '<<text.substr(arr[i].indx)<<endl;
}

int lcp(int x, int y) {
    int k, ret = 0;
    if (x == y) return n - x;
    for (k = step - 1; k >= 0 && x < n && y < n; k--) {
        if (sorted[k][x] == sorted[k][y]) {
            x += (1 << k);
            y += (1 << k);
            ret += (1 << k);
        }
    }
    return ret;
}

int LCP(int id1, int id2)
{
    if(id1 == id2) return n-id1;
    int ret = 0;
    int i, j;
    for(i = 1; i < n; i++)
    {
        for(j = step - 1; j >= 0 && id1 < n && id2 < n; j--)
            if(sorted[j][id1] == sorted[j][id2])
            {
                ret += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
    return ret;
//    for(i = 0; i < n; i++)
//        cout << i << ' ' << LCP[i] << endl;
}

bool ok(int l, int r, int len)
{
    if(LCP(l, r) >= len)
        return true;
    if(len % 2)
        return false;
    if(ok(l, r, len/2) && ok(l+(len/2), r + (len/2), len/2))
        return true;
    if(ok(l, r+(len/2), len/2) && ok(l+(len/2), r, len/2))
        return true;
    return false;
}

bool eq(int a, int b, int c, int d) {
    int l;
    l = b - a + 1;
    if (LCP(a, c) >= l) return true;
    if (l % 2 == 1) return false;
    return (eq(a, (a + b) / 2, (c + d) / 2 + 1, d) && eq((a + b) / 2 + 1, b, c, (c + d) / 2))
           || (eq(a, (a + b) / 2, c, (c + d) / 2) && eq((a + b) / 2 + 1, b, (c + d) / 2 + 1, d));
}

char s[MAX];

int main()
{
    scanf("%s %s", text, s);
    n = strlen(text);
    int i = 0;
    while(s[i])
        text[n++] = s[i++];
    build_suffix_array();
    if(eq(0, n-i-1, n-i, n-1))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


#include <bits/stdc++.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 400010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
struct info
{
    int tup[2], indx; //tup[0] = prev rank, tup[1] = new rank
}arr[MAX];
char str[MAX];

int sorted[20][MAX], step;
string text;

bool comp(const info &a, const info &b)
{
    return a.tup[0] != b.tup[0]? a.tup[0] < b.tup[0] : a.tup[1] < b.tup[1];
}

void build_suffix_array(void)
{
    int i, n = SZ(text), jump;
    for(i = 0; i < n; i++)
    {
        sorted[0][i] = text[i] - 'a'+1; //rank suffixes according to 1st char
//        clr(arr[i].tup, 0);
    }
    for(step = 1, jump = 1; jump <= n; step++, jump <<= 1)
    {
        for(i = 0; i <=n; i++)
        {
            arr[i].indx = i;
            arr[i].tup[0] = sorted[step - 1][i]; // what i was in prev step
            arr[i].tup[1] = i + jump < n? sorted[step - 1][i + jump] : -1;
        }
        sort(arr, arr + n, comp);
        sorted[step][arr[0].indx] = 0;
        for(i = 1; i < n; i++)
            sorted[step][arr[i].indx] = arr[i].tup[0] == arr[i - 1].tup[0] &&
            arr[i].tup[1] == arr[i - 1].tup[1] ? sorted[step][arr[i - 1].indx] : i;
    }
//    cout << "Suffix Array : \n\n";
//    for(i = 0; i < n; i++)
//        cout<<arr[i].indx<<' '<<text.substr(arr[i].indx)<<endl;
}

int LCP(int id1, int id2)
{
    int ret = 0;
    int n = SZ(text), i, j;
    for(i = 1; i < n; i++)
    {
        for(j = step - 1; j >= 0; j--)
            if(sorted[j][id1] == sorted[j][id2] && sorted[j][id1])
            {
                ret += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
    return ret;
//    for(i = 0; i < n; i++)
//        cout << i << ' ' << LCP[i] << endl;
}

string s1, s2;
map <pair<int,int>, int> lenmap;
map <pair<int,int>, bool> dp;

bool ok(int l, int r, int len)
{
    pair <int,int> look = mp(l, r);
    bool &ret = dp[look];
    if(lenmap.find(look) != lenmap.end())
    {
        if(lenmap[look] >= len)
            return dp[look];
    }
    lenmap[look] = len;
    if(LCP(l, r) >= len)
        return ret = true;
    if(len % 2)
        return ret = false;
    if(ok(l, r, len/2) && ok(l+(len/2), r + (len/2), len/2))
        return ret = true;
    if(ok(l, r+(len/2), len/2) && ok(l+(len/2), r, len/2))
        return ret = true;
    return ret = false;
}

int main()
{
    scanf(" %s", str);
    s1 = str;
    scanf(" %s", str);
    s2 = str;
    text = s1 + "#" + s2;
    build_suffix_array();
    if(ok(0, SZ(s1)+1, SZ(s1)))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


#include <bits/stdc++.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 400010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
struct info
{
    int tup[2], indx; //tup[0] = prev rank, tup[1] = new rank
}arr[MAX];
char str[MAX];

int sorted[20][MAX], step;
string text;

bool comp(const info &a, const info &b)
{
    return a.tup[0] != b.tup[0]? a.tup[0] < b.tup[0] : a.tup[1] < b.tup[1];
}

void build_suffix_array(void)
{
    int i, n = SZ(text), jump;
    for(i = 0; i < n; i++)
    {
        sorted[0][i] = text[i] - 'a'+1; //rank suffixes according to 1st char
//        clr(arr[i].tup, 0);
    }
    for(step = 1, jump = 1; jump <= n; step++, jump <<= 1)
    {
        for(i = 0; i <=n; i++)
        {
            arr[i].indx = i;
            arr[i].tup[0] = sorted[step - 1][i]; // what i was in prev step
            arr[i].tup[1] = i + jump < n? sorted[step - 1][i + jump] : -1;
        }
        sort(arr, arr + n, comp);
        sorted[step][arr[0].indx] = 0;
        for(i = 1; i < n; i++)
            sorted[step][arr[i].indx] = arr[i].tup[0] == arr[i - 1].tup[0] &&
            arr[i].tup[1] == arr[i - 1].tup[1] ? sorted[step][arr[i - 1].indx] : i;
    }
//    cout << "Suffix Array : \n\n";
//    for(i = 0; i < n; i++)
//        cout<<arr[i].indx<<' '<<text.substr(arr[i].indx)<<endl;
}

int LCP(int id1, int id2)
{
    int ret = 0;
    int n = SZ(text), i, j;
    for(i = 1; i < n; i++)
    {
        for(j = step - 1; j >= 0; j--)
            if(sorted[j][id1] == sorted[j][id2] && sorted[j][id1])
            {
                ret += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
    return ret;
//    for(i = 0; i < n; i++)
//        cout << i << ' ' << LCP[i] << endl;
}

string s1, s2;
map <tuple<int,int, int>, bool> mpp;

bool ok(int l, int r, int len)
{
    tuple <int,int, int> look = make_tuple(l, r, len);
    if(mpp.find(look) != mpp.end())
        return mpp[look];
    bool &ret = mpp[look];
    if(LCP(l, r) >= len)
        return ret = true;
    if(len % 2)
        return ret = false;
    if(ok(l, r, len/2) && ok(l+(len/2), r + (len/2), len/2))
        return ret = true;
    if(ok(l, r+(len/2), len/2) && ok(l+(len/2), r, len/2))
        return ret = true;
    return ret = false;
}

int main()
{
//    in;
    scanf(" %s", str);
    s1 = str;
    scanf(" %s", str);
    s2 = str;
    text = s1 + "#" + s2;
    build_suffix_array();
    if(ok(0, SZ(s1)+1, SZ(s1)))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


#include <bits/stdc++.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 400010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
struct info
{
    int tup[2], indx; //tup[0] = prev rank, tup[1] = new rank
}arr[MAX];

int sorted[20][MAX], step;
string text;

bool comp(const info &a, const info &b)
{
    return a.tup[0] != b.tup[0]? a.tup[0] < b.tup[0] : a.tup[1] < b.tup[1];
}

void build_suffix_array(void)
{
    int i, n = SZ(text), jump;
    for(i = 0; i < n; i++)
    {
        sorted[0][i] = text[i] - 'a'; //rank suffixes according to 1st char
//        clr(arr[i].tup, 0);
    }
    for(step = 1, jump = 1; jump <= n; step++, jump <<= 1)
    {
        for(i = 0; i <=n; i++)
        {
            arr[i].indx = i;
            arr[i].tup[0] = sorted[step - 1][i]; // what i was in prev step
            arr[i].tup[1] = i + jump < n? sorted[step - 1][i + jump] : -1;
        }
        sort(arr, arr + n, comp);
        sorted[step][arr[0].indx] = 0;
        for(i = 1; i < n; i++)
            sorted[step][arr[i].indx] = arr[i].tup[0] == arr[i - 1].tup[0] &&
            arr[i].tup[1] == arr[i - 1].tup[1] ? sorted[step][arr[i - 1].indx] : i;
    }
//    cout << "Suffix Array : \n\n";
//    for(i = 0; i < n; i++)
//        cout<<arr[i].indx<<' '<<text.substr(arr[i].indx)<<endl;
}

int LCP(int id1, int id2)
{
    int ret = 0;
    int n = SZ(text), i, j;
    for(i = 1; i < n; i++)
    {
        for(j = step - 1; j >= 0; j--)
            if(sorted[j][id1] == sorted[j][id2])
            {
                ret += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
    return ret;
//    for(i = 0; i < n; i++)
//        cout << i << ' ' << LCP[i] << endl;
}

string s1, s2;

bool ok(int l, int r, int len)
{
    if(LCP(l, r) >= len)
        return true;
    if(len % 2)
        return false;
    if(ok(l, r, len/2) && ok(l+(len/2), r + (len/2), len/2))
        return true;
    if(ok(l, r+(len/2), len/2) && ok(l+(len/2), r, len/2))
        return true;
    return false;
}

bool eq(int a, int b, int c, int d) {
    int l;
    l = b - a + 1;
    if (LCP(a, c) >= l) return true;
    if (l % 2 == 1) return false;
    return (eq(a, (a + b) / 2, (c + d) / 2 + 1, d) && eq((a + b) / 2 + 1, b, c, (c + d) / 2))
           || (eq(a, (a + b) / 2, c, (c + d) / 2) && eq((a + b) / 2 + 1, b, (c + d) / 2 + 1, d));
}

int main()
{
    cin >> s1 >> s2;
    text = s1 + s2;
    build_suffix_array();
    if(eq(0, SZ(s1)-1, SZ(s1), SZ(text)-1))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


#include <bits/stdc++.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 400010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/
struct info
{
    int tup[2], indx; //tup[0] = prev rank, tup[1] = new rank
}arr[MAX];

int n, sorted[20][MAX], step;
char text[MAX];

bool comp(const info &a, const info &b)
{
    return a.tup[0] != b.tup[0]? a.tup[0] < b.tup[0] : a.tup[1] < b.tup[1];
}

void build_suffix_array(void)
{
    int i, jump;
    for(i = 0; i < n; i++)
    {
        sorted[0][i] = text[i] - 'a'; //rank suffixes according to 1st char
//        clr(arr[i].tup, 0);
    }
    for(step = 1, jump = 1; jump <= n; step++, jump <<= 1)
    {
        for(i = 0; i <=n; i++)
        {
            arr[i].indx = i;
            arr[i].tup[0] = sorted[step - 1][i]; // what i was in prev step
            arr[i].tup[1] = i + jump < n? sorted[step - 1][i + jump] : -1;
        }
        sort(arr, arr + n, comp);
        sorted[step][arr[0].indx] = 0;
        for(i = 1; i < n; i++)
            sorted[step][arr[i].indx] = arr[i].tup[0] == arr[i - 1].tup[0] &&
            arr[i].tup[1] == arr[i - 1].tup[1] ? sorted[step][arr[i - 1].indx] : i;
    }
//    cout << "Suffix Array : \n\n";
//    for(i = 0; i < n; i++)
//        cout<<arr[i].indx<<' '<<text.substr(arr[i].indx)<<endl;
}

int lcp(int x, int y) {
    int k, ret = 0;
    if (x == y) return n - x;
    for (k = step - 1; k >= 0 && x < n && y < n; k--) {
        if (sorted[k][x] == sorted[k][y]) {
            x += (1 << k);
            y += (1 << k);
            ret += (1 << k);
        }
    }
    return ret;
}

int LCP(int id1, int id2)
{
    int ret = 0;
    int i, j;
    for(i = 1; i < n; i++)
    {
        for(j = step - 1; j >= 0 && id1 < n && id2 < n; j--)
            if(sorted[j][id1] == sorted[j][id2])
            {
                ret += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
    return ret;
//    for(i = 0; i < n; i++)
//        cout << i << ' ' << LCP[i] << endl;
}

bool ok(int l, int r, int len)
{
    if(LCP(l, r) >= len)
        return true;
    if(len % 2)
        return false;
    if(ok(l, r, len/2) && ok(l+(len/2), r + (len/2), len/2))
        return true;
    if(ok(l, r+(len/2), len/2) && ok(l+(len/2), r, len/2))
        return true;
    return false;
}

bool eq(int a, int b, int c, int d) {
    int l;
    l = b - a + 1;
    if (LCP(a, c) >= l) return true;
    if (l % 2 == 1) return false;
    return (eq(a, (a + b) / 2, (c + d) / 2 + 1, d) && eq((a + b) / 2 + 1, b, c, (c + d) / 2))
           || (eq(a, (a + b) / 2, c, (c + d) / 2) && eq((a + b) / 2 + 1, b, (c + d) / 2 + 1, d));
}

char s[MAX];

int main()
{
    scanf("%s %s", text, s);
    n = strlen(text);
    int i = 0;
    while(s[i])
        text[n++] = s[i++];
    build_suffix_array();
    if(eq(0, n-i-1, n-i, n-1))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string st[4];
    st[0]=s.substr(0,mid),st[1]=s.substr(mid,mid);
    if(s.size()%2){
        st[3]=s.substr(1,mid);
        st[4]=s.substr(mid+1,mid);
        st[0]=hsh(st[0]);st[1]=hsh(st[1]);
        st[2]=hsh(st[2]);st[3]=hsh(st[3]);
        if(min(st[3],st[4])<min(st[0],st[1])){
            st[0]=st[3];
            st[1]=st[4];
        }
    }
    else
        st[0]=hsh(st[0]);st[1]=hsh(st[1]);
    if(st[1]<st[0])
        s=st[1]+st[0];
    else
        s=st[0]+st[1];
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,mid),s3=s;
    if(s.size()%2){
        s3=s.substr(mid+1,mid);
        s2=min(s2,s3);
    }
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < int, int >pii;
const int maxn=1e5+1,inf=1e9+1;
string hsh(string s){
    if(s.size()==1)
        return s;
    string t[7];
    int mid=s.size()/2;
    t[0]=s.substr(0,mid),t[1]=s.substr(mid);
    t[0]=hsh(t[0]);
    t[1]=hsh(t[1]);
    if(s.size()%2)
        t[1][t[1].size()-1]=NULL;
    if(t[1]<t[0])
        s=t[1]+t[0];
    else
        s=t[0]+t[1];
    return s;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < int, int >pii;
const int maxn=1e5+1,inf=1e9+1;
string hsh(string s){
    if(s.size()==1)
        return s;
    string t[7];
    int mid=s.size()/2;
    t[0]=s.substr(0,mid),t[1]=s.substr(mid,mid);
    t[0]=hsh(t[0]);
    t[1]=hsh(t[1]);
    if(s.size()%2)
        t[1].push_back(s[s.size()-1]);
    if(t[1]<t[0])
        s=t[1]+t[0];
    else
        s=t[0]+t[1];
    return s;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,mid);
    s1=hsh(s1);s2=hsh(s2);
    char c;
    if(s.size()%2)
        c=s[s.size()-1];
    if(s2<s1)
        s=s2+s1+c;
    else
        s=s1+s2+c;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < int, int >pii;
const int maxn=1e5+1,inf=1e9+1;
string hsh(string s){
    if(s.size()==1)
        return s;
    string t[7];
    int mid=s.size()/2;
    t[0]=s.substr(0,mid),t[1]=s.substr(mid,mid);
    if(s.size()%2){
        t[2]=s.substr(1,mid);
        t[3]=s.substr(mid+1,mid);
        for(int i=0;i<4;i++)
            t[i]=hsh(t[i]);
        t[4]=min(t[2],t[3]);
        t[5]=min(t[0],t[3]);
        t[6]=min(t[0],t[1]);
        if(t[4]<=t[5] && t[4]<=t[6]){
            t[0]=t[2];
            t[1]=t[3];
        }
        else if(t[5]<=t[4] && t[5]<=t[6]){
            t[1]=t[3];
        }
    }
    else{
        t[0]=hsh(t[0]);
        t[1]=hsh(t[1]);
    }
    if(t[1]<t[0])
        s=t[1]+t[0];
    else
        s=t[0]+t[1];
    return s;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,s.size()-mid);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2;
    if(s.size()%2)
        s2=s.substr(mid+1,mid);
    else
        s2=s.substr(mid,mid);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,mid);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < int, int >pii;
const int maxn=1e5+1,inf=1e9+1;
string hsh(string s){
    if(s.size()==1)
        return s;
    string t[7];
    int mid=s.size()/2;
    t[0]=s.substr(0,mid),t[1]=s.substr(mid,mid);
    if(s.size()%2){
        t[2]=s.substr(1,mid);
        t[3]=s.substr(mid+1,mid);
        for(int i=0;i<4;i++)
            t[i]=hsh(t[i]);
        if(min(t[2],t[3])<min(t[0],t[1])){
            t[0]=t[2];
            t[1]=t[3];
        }
    }
    else{
        t[0]=hsh(t[0]);
        t[1]=hsh(t[1]);
    }
    if(t[1]<t[0])
        s=t[1]+t[0];
    else
        s=t[0]+t[1];
    return s;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,mid),s3;
    if(s.size()%2)
        s3=s.substr(mid+1,mid);
    s2=min(s2,s3);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


//IN THE NAME OF ALLAH

#include <bits/stdc++.h>
using namespace std;
string hsh(string s){
    if(s.size()==1 || s.size()%2)
        return s;
    int mid=s.size()/2;
    string s1=s.substr(0,mid),s2=s.substr(mid,mid);
    s1=hsh(s1);s2=hsh(s2);
    if(s2<s1)
        s=s2+s1;
    else
        s=s1+s2;
    return s;
}
int main(){
    string s,t;
    cin>>s>>t;
    if(hsh(s)==hsh(t))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  if(ll == lh && rl == rh) return a[ll] == b[rl];
  bool f = true;
  int i = ll , j = rl;
  while(i <= lh && j <= rh) {
    if(a[i] != b[j]) {
      f = false;
      break;
    }
    i ++; j ++;
  }
  if(f) return f;
  if(!((lh-ll) & 1)) return false;
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  f = (f1 && f3) || (f2 && f4);
  return f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
string smallest(string s) {
  if(SZ(s) & 1) return s;
  string a = smallest(s.substr(0,SZ(s)/2));
  string b = smallest(s.substr(SZ(s)/2,SZ(s)/2));
  if(a < b)
    return a + b;
  return b + a;
}
int main() {
  fast_io;
  string a,b;
  cin >> a >> b;
  string A = smallest(a);
  string B = smallest(b);
  if(A == B) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  if(ll == lh && rl == rh)
    return a[ll] == b[rl];
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  bool f = (f1 && f3) || (f2 && f4);
  return f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  bool f = true;
  int i = ll , j = rl;
  while(i <= lh && j <= rh) {
    if(a[i] != b[j]) {
      f = false;
      break;
    }
    i ++; j ++;
  }
  if(f) return f;
  if((lh-ll+1) & 1) return false;
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  return ((f1 && f3) || (f2 && f4));
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  bool f = true;
  int i = ll , j = rl;
  while(i <= lh && j <= rh) {
    if(a[i] != b[j]) {
      f = false;
      break;
    }
    i ++; j ++;
  }
  if(f) return f;
  if((lh-ll) % 2 == 0) return false;
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  f = (f1 && f3) || (f2 && f4);
  return f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(rh-rl != lh-ll || ll > lh || rl > rh) return false;
  bool f = true;
  int i = 0;
  while(ll + i <= lh) {
    if(a[ll+i] != b[rl+i]) {
      f = false;
      break;
    }
    i ++;
  }
  if(f) return f;
  if((lh-ll+1) & 1) return false;
  return ((solve(ll , (ll + lh)/2 , rl , (rl + rh)/2) && solve((ll + lh)/2+1 , lh , (rl + rh)/2+1 , rh)) || (solve(ll , (ll + lh)/2 , (rl + rh)/2+1 , rh) && solve((ll + lh)/2+1 , lh , rl , (rl + rh)/2)));
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
map < II , bool> dp;
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  if(ll == lh && rl == rh)
    return a[ll] == b[rl];
  if(dp.count((MP(ll,rl)))) return dp[MP(ll,rl)];
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  bool f = (f1 && f3) || (f2 && f4);
  return dp[MP(ll,rl)] = f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  if(ll == lh && rl == rh) return a[ll] == b[rl];
  bool f = true;
  int i = ll , j = rl;
  while(i <= lh && j <= rh) {
    if(a[i] != b[j]) f = false;
    i ++; j ++;
  }
  if(f) return f;
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  f = (f1 && f3) || (f2 && f4);
  return f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
bool solve(int ll , int lh , int rl , int rh) {
  if(rh-rl != lh-ll || ll > lh || rl > rh) return false;
  bool f = true;
  int i = ll , j = rl;
  while(i <= lh && j <= rh) {
    if(a[i] != b[j]) {
      f = false;
      break;
    }
    i ++; j ++;
  }
  if(f) return f;
  if((lh-ll+1) & 1) return false;
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  return ((solve(ll , lm , rl , rm) && solve(lm+1 , lh , rm+1 , rh)) || (solve(ll , lm , rm+1 , rh) && solve(lm+1 , lh , rl , rm)));
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES");
  else puts("NO");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define endl '\n'
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
char a[N] , b[N];
map <pair <II,II> , bool> dp;
bool solve(int ll , int lh , int rl , int rh) {
  if(ll > lh || rl > rh) return false;
  if(ll == lh && rl == rh)
    return a[ll] == b[rl];
  if(dp.count(MP(MP(ll,lh),MP(rl,rh)))) return dp[MP(MP(ll,lh),MP(rl,rh))];
  int lm = (ll + lh)/2 , rm = (rl + rh)/2;
  bool f1 = solve(ll , lm , rl , rm);
  bool f2 = solve(ll , lm , rm+1 , rh);
  bool f3 = solve(lm+1 , lh , rm+1 , rh);
  bool f4 = solve(lm+1 , lh , rl , rm);
  bool f = (f1 && f3) || (f2 && f4);
  return dp[MP(MP(ll,lh),MP(rl,rh))] = f;
}
int main() {
  scanf("%s%s",a,b);
  int n = strlen(a);
  if(solve(0,n-1,0,n-1)) puts("YES\n");
  else puts("NO");
  return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using std::cin;
#include<algorithm>
using std::min;
#include<string>
using std::string;

string a,b;

string sort(string);

int main(void){
    cin>>a>>b;
    puts(sort(a)==sort(b)?"YES":"NO");
    return 0;
}

string sort(string str){
    if(str.length()&1)
        return str;
    else{
        string k=sort(str.substr(0,str.length()>>1));
        string l=sort(str.substr(str.length()>>1));
        return min(k+l,l+k);
    }
}


#include<cstdio>
#include<iostream>
using namespace std;
string A,B;
string Equivalent(string x)
{
	string a,b;
	if(x.size()%2)return x;
	else
	{
		a=x.substr(0,x.size()/2);
		b=x.substr(x.size()/2,x.size()/2);
//		cout<<x<<" "<<a<<" "<<b<<endl;
		if(a>b)
		return Equivalent(b)+Equivalent(a);
		else
		return Equivalent(a)+Equivalent(b);
	}
}
int main()
{
	cin>>A>>B;
	if(Equivalent(A)==Equivalent(B))
		cout<<"YES";
	else
		cout<<"NO";
}


//
//  main.cpp
//  sim
//
//  Created by gengyf on 2019/6/15.
//  Copyright © 2019 yifan Geng. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
string s,t;
int T;
string cmp(string s){
    int len=s.length();
    if(len&1) return s;
    string s1=cmp(s.substr(0,len/2));
    string s2=cmp(s.substr(len/2,len/2));
    if (s1<s2) return s1+s2;
    return s2+s1;
}
int main() {
    cin>>s>>t;
    if(cmp(s).compare(cmp(t))==0){
        printf("YES\n");
    }
    else printf("NO\n");
    return 0;
}


#include <bits/stdc++.h>

bool is_equal(const std::string &a, int pos_a, int len_a, const std::string &b, int pos_b, int len_b) {
	if (a.compare(pos_a, len_a, b, pos_b, len_b) == 0) {
		return true;
	}

	if (a.size() == 1) {
		return a == b;
	}

	int n = len_a;
	if (n % 2 == 0) {
		if (is_equal(a, pos_a, n / 2, b, pos_b, n / 2) && is_equal(a, pos_a + n / 2, n / 2, b, pos_b + n / 2, n / 2)) {
			return true;
		}
		if (is_equal(a, pos_a, n / 2, b, pos_b + n / 2, n / 2) && is_equal(a, pos_a + n / 2, n / 2, b, pos_b, n / 2)) {
			return true;
		}
	}

	return false;
}

int main() {
	std::string a;
	std::string b;

	std::cin >> a;
	std::cin >> b;

	if (is_equal(a, 0, a.size(), b, 0, b.size())) {
		std::cout << "YES\n";
	}
	else {
		std::cout << "NO\n";
	}

	return 0;
}


#include <iostream>

#include <cstring>

#include <string>

#include <string.h>

#include <cstdio>

#include <algorithm>

using namespace std;

typedef long long LL;

#define max(a,b) (a>b?a:b)

#define min(a,b) (a<b?a:b)

bool find(string a,string b,int len)

{

	if(a==b)return true;

	if(len&1)

		return false;

	string a1,a2,b1,b2;

	len>>=1;

	for(int i=0;i<len;++i)

	{

		a1+=a[i];

		a2+=a[i+len];

		b1+=b[i];

		b2+=b[i+len];

	}

	if((find(a1,b2,len)&&find(a2,b1,len))||(find(a1,b1,len)&&find(a2,b2,len)))// || 前后的条件交换顺序就超时了....

		return true;

	return false;

}

int main()

{

	string a,b;

	while(cin>>a>>b)

	{

		int len=a.length();

		if(find(a,b,len))

			cout<<"YES"<<endl;

		else

			cout<<"NO"<<endl;

	}

	return 0;

}


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


#include<cstdio>
#include<cstring>
int const Max = 250000;
char a[Max], b[Max];

bool isequal(char *a, char *b, int length)
{
    if (!strncmp(a, b, length))
        return true;
    if (length % 2)
        return false;
    int mid = length / 2;
    if (isequal(a, b + mid, mid) && isequal(a + mid, b, mid))
        return true;
    if (isequal(a, b, mid) && isequal(a + mid, b + mid, mid))
        return true;
    return false;

}

int main()
{
    scanf("%s%s", a, b);
    printf("%s\n", isequal(a, b, strlen(a)) ? "YES" : "NO");

}


#include<iostream>
#include<string>
using namespace std;
typedef string::size_type sz;

const string outp[2]={"NO","YES"};

string mysplit(const string& s)
{
    if(s.size()&1)
    {
        return s;
    }

    string a1=mysplit(s.substr(0,s.size()/2));
    string a2=mysplit(s.substr(s.size()/2,s.size()/2));

    return (a1<a2)?(a1+a2):(a2+a1);
}

bool myequivalent(const string&a, const string& b)
{
    return a==b;
}

int main()
{
    string a,b;
    cin>>a>>b;
    cout<<outp[myequivalent(mysplit(a),mysplit(b))];
    return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
string A,B;
string Equivalent(string x)
{
	string a,b;
	if(x.size()%2)return x;
	else
	{
		a=x.substr(0,x.size()/2);
		b=x.substr(x.size()/2,x.size()/2);
//		cout<<x<<" "<<a<<" "<<b<<endl;
		if(a>b)
		return Equivalent(b)+Equivalent(a);
		else
		return Equivalent(a)+Equivalent(b);
	}
}
int main()
{
	cin>>A>>B;
	if(Equivalent(A)==Equivalent(B))
		printf("YES");
	else
		printf("NO");
}


#include<iostream>
#include<string>
using namespace std;
typedef string::size_type sz;

struct spre
{
    string b1,b2;
};

const string outp[2]={"NO","YES"};

spre mysplit(const string& s)
{
    spre temp;
    temp.b1=s.substr(0,s.size()/2);
    temp.b2=s.substr(s.size()/2,s.size());
    return temp;
}

bool myequivalent(const string&a, const string& b)
{
    if (a.size()%2==1)
    {
        if(a==b)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        //string a1=mysplit(a).b1;
        //string a2=mysplit(a).b2;
        //string b1=mysplit(b).b1;
        //string b2=mysplit(b).b2;
        if(myequivalent(mysplit(a).b1,mysplit(b).b1)&&myequivalent(mysplit(a).b2,mysplit(b).b2))
        {
            return true;
        }
        else if (myequivalent(mysplit(a).b1,mysplit(b).b2)&&myequivalent(mysplit(a).b2,mysplit(b).b1))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

int main()
{
    string a,b;
    cin>>a>>b;
    cout<<outp[myequivalent(a,b)];
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
typedef string::size_type sz;

struct spre
{
    string b1,b2;
};

const string outp[2]={"NO","YES"};

spre mysplit(const string& s)
{
    spre temp;
    temp.b1=s.substr(0,s.size()/2);
    temp.b2=s.substr(s.size()/2,s.size());
    return temp;
}

bool myequivalent(const string&a, const string& b)
{
    if(a==b)
    {
        return true;
    }
    else if (a.size()&1)
    {
        return false;
    }
    else
    {
        //string a1=mysplit(a).b1;
        //string a2=mysplit(a).b2;
        //string b1=mysplit(b).b1;
        //string b2=mysplit(b).b2;
        if(myequivalent(mysplit(a).b1,mysplit(b).b1)&&myequivalent(mysplit(a).b2,mysplit(b).b2))
        {
            return true;
        }
        else if (myequivalent(mysplit(a).b1,mysplit(b).b2)&&myequivalent(mysplit(a).b2,mysplit(b).b1))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

int main()
{
    string a,b;
    cin>>a>>b;
    cout<<outp[myequivalent(a,b)];
    return 0;
}


#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=200001;
string cm(string s)
{
	string a,b;
	if(s.size()&1)
	return s;
    a=s.substr(0,s.size()/2);
    b=s.substr(s.size()/2);
    a=cm(a);
    b=cm(b);
	return a<b?a+b:b+a;
}
int main()
{
	int l1,l2;
	string s1,s2;
	cin>>s1>>s2;
	l1=s1.length();
	l2=s2.length();
	if(l1!=l2)
	{
		printf("NO");
		return 0;
	}
	if(l1%2)
	{
	   if(s1==s2)
	   printf("YES");
	   else
	   printf("NO");
	   return 0;
	}
	if(cm(s2)==cm(s1))
	printf("YES");
	else
	printf("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

string s1, s2;

bool iseq(string s1, string s2) {
	if(s1 == s2) return true;
	int len = s1.size();
	if(len & 1) return false;
	string a1 = s1.substr(0, len/2);
	string a2 = s1.substr(len/2);
	string b1 = s2.substr(0, len/2);
	string b2 = s2.substr(len/2);
	if(iseq(a1, b2) && iseq(a2, b1)) return true;
	if(iseq(a1, b1) && iseq(a2, b2)) return true;
	return false;
}

int main() {
	cin >> s1 >> s2;

	if(iseq(s1, s2))
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

string s1, s2;

bool iseq(string s1, string s2) {
	if(s1 == s2) return true;
	int len = s1.size();
	if(len & 1) return false;
	else {
		string a1 = s1.substr(0, len/2);
		string a2 = s1.substr(len/2);
		string b1 = s2.substr(0, len/2);
		string b2 = s2.substr(len/2);
		return iseq(a1, b2) && iseq(a2, b1);
	}
}

int main() {
	cin >> s1 >> s2;

	if(iseq(s1, s2))
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	else if(f1==f2) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((go(fs1,fe1,ss1,se1))&(go(fs2,fe2,ss2,se2)))|((go(fs1,fe1,ss2,se2))&(go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	int len=strlen(str1);
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll inverse[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inverse[id1];
	cmp2*=inverse[sid1];
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int s1, int e1, int s2, int e2) {
	if(isEqual(s1,e1,s2,e2)) return true;
	else if((e1-s1+1)%2!=0) return false;
	int mid1=(s1+e1)/2;
	int mid2=(s2+e2)/2;
	return (((go(s1,mid1,mid2+1,e2)) and (go(mid1+1,e1,s2,mid2))) or ((go(s1,mid1,s2,mid2)) and (go(mid1+1,e1,mid2+1,e2))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	inverse[0]=1;
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		inverse[i]=inv(po);
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll inverse[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inverse[id1];
	cmp2*=inverse[sid1];
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int s1, int e1, int s2, int e2) {
	if(isEqual(s1,e1,s2,e2)) return true;
	else if((e1-s1+1)%2!=0) return false;
	int mid1=(s1+e1)/2;
	int mid2=(s2+e2)/2;
	return (((go(s1,mid1,mid2+1,e2)) & (go(mid1+1,e1,s2,mid2))) | ((go(s1,mid1,s2,mid2)) & (go(mid1+1,e1,mid2+1,e2))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	inverse[0]=1;
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		inverse[i]=inv(po);
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
bool go(int f1, int f2, int s1, int s2) {
	if(f1==f2 and s1==s2) return str1[f1]==str2[s1];
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return ((go(fs1,fe1,ss1,se1)&go(fs2,fe2,ss2,se2))|(go(fs1,fe1,ss2,se2)&go(fs2,fe2,ss1,se1)));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool isEquall(int id1, int id2, int sid1, int sid2) {
	for(int i=id1,j=sid1;i<=id2;i++,j++) if(str1[i]!=str2[j]) return false;
	return true;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEquall(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs1,fe1,ss1,se1)&go(fs2,fe2,ss2,se2))|(go(fs1,fe1,ss2,se2)&go(fs2,fe2,ss1,se1));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll inverse[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inverse[id1];
	cmp2*=inverse[sid1];
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs2,fe2,ss1,se1)&go(fs1,fe1,ss2,se2))|(go(fs1,fe1,ss1,se1)&go(fs2,fe2,ss2,se2));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	inverse[0]=1;
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		inverse[i]=inv(po);
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs1,fe1,ss1,se1)&go(fs2,fe2,ss2,se2))|(go(fs1,fe1,ss2,se2)&go(fs2,fe2,ss1,se1));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	else if(f1==f2) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((go(fs1,fe1,ss1,se1))&(go(fs2,fe2,ss2,se2)))|((go(fs1,fe1,ss2,se2))&(go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	int len=strlen(str1);
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	else if((f2-f1+1)%2!=0) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs1,fe1,ss1,se1) and go(fs2,fe2,ss2,se2)) or (go(fs1,fe1,ss2,se2) and go(fs2,fe2,ss1,se1));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	int len=strlen(str1);
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES":"NO")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll inverse[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inverse[id1];
	cmp2*=inverse[sid1];
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int s1, int e1, int s2, int e2) {
	if(isEqual(s1,e1,s2,e2)) return true;
	else if((e1-s1+1)%2!=0) return false;
	int mid1=(s1+e1)/2;
	int mid2=(s2+e2)/2;
	return (((go(s1,mid1,mid2+1,e2)) && (go(mid1+1,e1,s2,mid2))) || ((go(s1,mid1,s2,mid2)) && (go(mid1+1,e1,mid2+1,e2))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	inverse[0]=1;
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		inverse[i]=inv(po);
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(f1==f2 and s1==s2) return str1[f1]==str2[s1];
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((isEqual(fs1,fe1,ss1,se1) or go(fs1,fe1,ss1,se1))&(isEqual(fs2,fe2,ss2,se2) or go(fs2,fe2,ss2,se2)))|((isEqual(fs1,fe1,ss2,se2) or go(fs1,fe1,ss2,se2))&(isEqual(fs2,fe2,ss1,se1) or go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<sz(str1);i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((isEqual(fs1,fe1,ss1,se1) or go(fs1,fe1,ss1,se1))&(isEqual(fs2,fe2,ss2,se2) or go(fs2,fe2,ss2,se2)))|((isEqual(fs1,fe1,ss2,se2) or go(fs1,fe1,ss2,se2))&(isEqual(fs2,fe2,ss1,se1) or go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs2,fe2,ss1,se1)&go(fs1,fe1,ss2,se2))|(go(fs1,fe1,ss1,se1)&go(fs2,fe2,ss2,se2));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	int len=strlen(str1);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((isEqual(fs1,fe1,ss1,se1) or go(fs1,fe1,ss1,se1))&(isEqual(fs2,fe2,ss2,se2) or go(fs2,fe2,ss2,se2)))|((isEqual(fs1,fe1,ss2,se2) or go(fs1,fe1,ss2,se2))&(isEqual(fs2,fe2,ss1,se1) or go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<sz(str1);i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((isEqual(fs1,fe1,ss1,se1) or go(fs1,fe1,ss1,se1))&(isEqual(fs2,fe2,ss2,se2) or go(fs2,fe2,ss2,se2)))|((isEqual(fs1,fe1,ss2,se2) or go(fs1,fe1,ss2,se2))&(isEqual(fs2,fe2,ss1,se1) or go(fs2,fe2,ss1,se1))));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<sz(str1);i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		if(po>=MOD) po%=MOD;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
bool go(int f1, int f2, int s1, int s2) {
	if(f1==f2 and s1==s2) return str1[f1]==str2[s1];
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	return ((go(f1,mid1,s1,mid2)&go(mid1+1,f2,mid2+1,s2))|(go(f1,mid1,mid2+1,s2)&go(mid1+1,f2,s1,mid2)));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
char str1[MAXN],str2[MAXN];
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	else if(f1==f2) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (go(fs1,fe1,ss1,se1) and go(fs2,fe2,ss2,se2)) or (go(fs1,fe1,ss2,se2) and go(fs2,fe2,ss1,se1));
}
int main() {
	//freopen("TASK.in","r",stdin);
	//freopen("TASK.out","w",stdout);
	scanf("%s%s",str1,str2);
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	int len=strlen(str1);
	for(int i=1;i<len;i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,len-1,0,len-1)?"YES":"NO")<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

typedef long long ll;
typedef pair<int,int> pii;
string str1,str2;
const ll BASE=37;
const ll MOD = 1e9+7;
const int MAXN = 2e5+5;
ll h1[MAXN],h2[MAXN];
ll power(ll a, ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret*=a;
		a*=a;
		if(a>=MOD) a%=MOD;
		if(ret>=MOD) ret%=MOD;
		b>>=1;
	}
	return ret;
}
ll inv(ll x) {
	return power(x,MOD-2);
}
bool isEqual(int id1, int id2, int sid1, int sid2) {
	ll cmp1=h1[id2]-(id1!=0?h1[id1-1]:0);
	if(cmp1<0) cmp1+=MOD;
	ll cmp2=h2[sid2]-(sid1!=0?h2[sid1-1]:0);
	if(cmp2<0) cmp2+=MOD;
	cmp1*=inv(power(BASE,id1));
	cmp2*=inv(power(BASE,sid1));
	if(cmp1>=MOD) cmp1%=MOD;
	if(cmp2>=MOD) cmp2%=MOD;
	return cmp1==cmp2;
}
bool go(int f1, int f2, int s1, int s2) {
	if(isEqual(f1,f2,s1,s2)) return true;
	if((f2-f1+1)%2==1) return false;
	int mid1=(f1+f2)/2;
	int mid2=(s1+s2)/2;
	int fs1,fe1,fs2,fe2,ss1,se1,ss2,se2;
	if((f2-f1+1)%2==0) {
		fs1=f1;
		fe1=mid1;
		fs2=mid1+1;
		fe2=f2;
	}
	else {
		fs1=f1;
		fe1=mid1-1;
		fs2=mid1+1;
		fe2=f2;
	}
	if((s2-s1+1)%2==0) {
		ss1=s1;
		se1=mid2;
		ss2=mid2+1;
		se2=s2;
	}
	else {
		ss1=s1;
		se1=mid2-1;
		ss2=mid2+1;
		se2=s2;
	}
	return (((isEqual(fs1,fe1,ss1,se1) or go(fs1,fe1,ss1,se1))&(isEqual(fs2,fe2,ss2,se2) or go(fs2,fe2,ss2,se2)))|((isEqual(fs1,fe1,ss2,se2) or go(fs1,fe1,ss2,se2))&(isEqual(fs2,fe2,ss1,se1) or go(fs2,fe2,ss1,se1))));
}
int main() {
//	freopen("TASK.in","r",stdin);
//	freopen("TASK.out","w",stdout);
	cin>>str1>>str2;
	h1[0]=str1[0]-'a';
	h2[0]=str2[0]-'a';
	ll po=1;
	for(int i=1;i<sz(str1);i++) {
		h1[i]=h1[i-1];
		h2[i]=h2[i-1];
		po*=BASE;
		ll temp=str1[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h1[i]+=temp;
		if(h1[i]>=MOD) h1[i]-=MOD;
		temp=str2[i]-'a';
		temp*=po;
		if(temp>=MOD) temp%=MOD;
		h2[i]+=temp;
		if(h2[i]>=MOD) h2[i]-=MOD;
	}
	cout<<(go(0,sz(str1)-1,0,sz(str1)-1)?"YES\n":"NO\n")<<endl;
	return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;

string eq(int xs, int xe, int ys, int ye) {
    if (x.substr(xs, xe - xs) == y.substr(ys, ye - ys)) {
        return "YES";
    } else {
        if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
            if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == "YES" && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == "YES")
                    || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == "YES" && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == "YES")) {
                return "YES";
            }
            return "NO";
        } else {

            return "NO";
        }
    }
}

int main() {

    cin >> x >> y;

    cout << eq(0, x.size(), 0, y.size());

    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;
int cont = 1;

string eq(int xs, int xe, int ys, int ye) {
    if (cont) {
        if (x.substr(xs,xe-xs)==y.substr(ys,ye-ys)) {
            return "YES";
        } else {
            if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
                if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == "YES" && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == "YES")
                        || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == "YES" && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == "YES")) {
                    return "YES";
                }
                cont = 0;
                return "NO";
            } else {
                cont = 0;
                return "NO";
            }
        }
    }
    return "NO";
}

int main() {

    cin >> x >> y;

    cout << eq(0, x.size(), 0, y.size());

    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

int eq(char *a, char *b, int l) {

    bool flag = true;
    for (int i = 0; i < l; i++)
        if (a[i] != b[i]) {
            flag = false;
            break;
        }
    if (flag)
        return 1;

    if (l % 2 != 0)
        return 0;
    else if (eq(a, b, l / 2) && eq(a + l / 2, b + l / 2, l / 2))
        return 1;
    else if (eq(a, b + l / 2, l / 2) && eq(a + l / 2, b, l / 2))
        return 1;

    return 0;
}

int main() {
    char s[200004], s1[200004];
    string a, b;
    cin >> a >> b;
    int size = a.size();

    FOR(i, 0, size) {
        s[i] = a[i];
        s1[i] = b[i];
    }
    if (eq(s, s1, size))
        cout << "YES";
    else
        cout << "NO";

    //   system("pause");
    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;
int eq(int xs, int xe, int ys, int ye) {
        if (x.substr(xs, xe - xs) == y.substr(ys, ye - ys)) {
            return 1;
        } else {
            if (((xe-xs) % 2 == 0)) {
                if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == 1 && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == 1)
                        || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == 1 && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == 1)) {
                    return 1;
                }
                return 0;
            } else {
                return 0;
            }
        }
}

int main() {

    cin >> x >> y;
    if(eq(0, x.size(), 0, y.size())){
    cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;

string eq(int xs, int xe, int ys, int ye) {
    if (x.substr(xs,xe-xs) == y.substr(ys,ye-ys)) {
        return "YES";
    } else {
        if (((xs+xe) % 2 == 0) && ((ys+ye) % 2 == 0)) {
            if (eq(xs, (xe+xs)/2, ys, (ye+ys)/2).append(eq((xe+xs)/2, xe, (ye+ys) /2, ye)) == "YESYES"
                    || eq(xs, (xe+xs)/2, (ye+ys)/2, ye).append(eq((xe+xs)/2, xe, ys, (ye+ys)/2)) == "YESYES") {
                    return "YES";
                }
            return "NO";
        } else {
            return "NO";
        }
    }
}

int main() {

    cin >> x >> y;

    cout << eq(0, x.size(),0,  y.size());

    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;
int cont = 1;

string eq(int xs, int xe, int ys, int ye) {
    if (cont) {
        if (x.substr(xs,xe-xs)==y.substr(ys,ye-ys)) {
            return "YES";
        } else {
            if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
                if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == "YES" && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == "YES")
                        || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == "YES" && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == "YES")) {
                    return "YES";
                }
                int cont = 0;
                return "NO";
            } else {
                int cont = 0;
                return "NO";
            }
        }
    }
    return "NO";
}

int main() {

    cin >> x >> y;

    cout << eq(0, x.size(), 0, y.size());

    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;
int eq(int xs, int xe, int ys, int ye) {
        if (x.substr(xs, xe - xs) == y.substr(ys, ye - ys)) {
            return 1;
        } else {
            if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
                if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == 1 && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == 1)
                        || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == 1 && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == 1)) {
                    return 1;
                }
                return 0;
            } else {
                return 0;
            }
        }
}

int main() {

    cin >> x >> y;
    if(eq(0, x.size(), 0, y.size())){
    cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;
int cont = 1;

string eq(int xs, int xe, int ys, int ye) {
    if (cont) {
        if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
            return "YES";
        } else {
            if (((xs + xe) % 2 == 0) && ((ys + ye) % 2 == 0)) {
                if (eq(xs, (xe + xs) / 2, ys, (ye + ys) / 2) == "YES" && (eq((xe + xs) / 2, xe, (ye + ys) / 2, ye) == "YES")
                        || (eq(xs, (xe + xs) / 2, (ye + ys) / 2, ye) == "YES" && eq((xe + xs) / 2, xe, ys, (ye + ys) / 2) == "YES")) {
                    return "YES";
                }
                int cont = 0;
                return "NO";
            } else {
                int cont = 0;
                return "NO";
            }
        }
    }
    return "NO";
}

int main() {

    cin >> x >> y;

    cout << eq(0, x.size(), 0, y.size());

    return 0;
}


//////////BEGIN TEMPLATE
#include<bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REV(i,b,a) for(int i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define SZ(v) (int)v.size()
#define sz(v) (int)v.size()
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define mem(s,v) memset(s,v,sizeof(s))
#define ppc(x) __builtin_popcount((x))
#define iter(it,s) for(__typeof(s.begin())it = s.begin();it!=s.end();it++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int OO = (int) 2e9;
const double eps = 1e-9;

// 1 based
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
#define Nd 0
#define Ed 1
#define Sd 2
#define Wd 3
//////////END TEMPLATE

string x, y;

string eq(string x, string y) {
    if (x == y) {
        return "YES";
    } else {
        if ((x.size() % 2 == 0) && (y.size() % 2 == 0)) {
            if(eq(x.substr(0,x.size()/2),y.substr(0,y.size()/2)).append(eq(x.substr(x.size()/2,x.size()/2),y.substr(y.size()/2,y.size()/2)))=="YESYES"
                    || eq(x.substr(0,x.size()/2),y.substr(y.size()/2,y.size()/2)).append(eq(x.substr(x.size()/2,x.size()/2),y.substr(0,y.size()/2)))=="YESYES" ){
                return "YES";
            }
            return "NO";
        } else {
            return "NO";
        }
    }
}

int main() {

    cin >> x >> y;

    cout << eq(x, y);

    return 0;
}