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

typedef long long ll;

bool check(string a, string b) {
	if(a == b) return true;

	int la = a.size(), lb=b.size();
	if(la&1 || lb&1) return false;
	if(la == 1) return false;

	string a1 = a.substr(0, la/2);
	string b1 = b.substr(0, lb/2);
	string a2 = a.substr(la/2, la/2);
	string b2 = b.substr(lb/2, lb/2);
	return (check(a1, b1) && check(a2, b2)) || (check(a1, b2) && check(a2, b1));
}

int main() {
	string a,b;
	cin >> a >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


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

typedef long long ll;

bool check(string a, string b) {
	if(a == b) return true;
	if(a.length() % 2 == 1) return false;
	if(a.length() == 1) return false;

	string a1 = a.substr(0, a.length()/2);
	string b1 = b.substr(0, b.length()/2);
	string a2 = a.substr(a.length()/2, a.length()/2);
	string b2 = b.substr(b.length()/2, b.length()/2);
	return (check(a1, b1) && check(a2, b2)) || (check(a1, b2) && check(a2, b1));
}

int main() {
	string a,b;
	cin >> a >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


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

typedef long long ll;

string a,b;
bool check(string a, string b) {
	if(a == b) return true;

	int la = a.size(), lb=b.size();
	if(la&1 || lb&1) return false;
	if(la == 1) return false;

	string a1 = a.substr(0, la/2);
	string b1 = b.substr(0, lb/2);
	string a2 = a.substr(la/2, la/2);
	string b2 = b.substr(lb/2, lb/2);
	return (check(a1, b2) && check(a2, b1)) || (check(a1, b1) && check(a2, b2));
}

int main() {
	cin >> a;
	cin >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


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

typedef long long ll;

string a,b;
bool check(string a, string b) {
	if(a == b) return true;

	int la = a.size(), lb=b.size();
	if(la&1 || lb&1) return false;
	if(la == 1) return false;

	string a1 = a.substr(0, la/2);
	string b1 = b.substr(0, lb/2);
	string a2 = a.substr(la/2, la/2);
	string b2 = b.substr(lb/2, lb/2);
	return (check(a1, b1) && check(a2, b2)) || (check(a1, b2) && check(a2, b1));
}

int main() {
	cin >> a;
	cin >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


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

typedef long long ll;

bool check(string a, string b) {
	if(a == b) return true;

	int l = a.length();
	if(l&1) return false;

	string a1 = a.substr(0, l/2);
	string b1 = b.substr(0, l/2);
	string a2 = a.substr(l/2, l/2);
	string b2 = b.substr(l/2, l/2);
	return (check(a1, b2) && check(a2, b1)) || (check(a1, b1) && check(a2, b2));
}

int main() {
	string a,b;
	cin >> a >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


#include<bits/stdc++.h>

typedef long long int ll;

using namespace std;

string s1,s2;
bool equ(string a,string b)
{
    if (a==b)
        return true;

    int la= a.size(),lb= b.size();

    if (la&1 || lb&1)
        return false;

    if (la==1)
        return false;

    string as1 = a.substr(0,la/2),as2 = a.substr(la/2,la/2);
    string bs1 = b.substr(0,lb/2),bs2 = b.substr(lb/2,lb/2);

    return (equ(as1,bs2) && equ(as2,bs1)) || (equ(as1,bs1) && equ(as2,bs2));
}

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

    if(equ(s1,s2))
        cout << "YES";
    else
        cout << "NO";

    return 0;
}


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

typedef long long ll;

bool check(string a, string b) {
	if(a == b) return true;
	if(a.length()&1) return false;
	if(a.length() == 1) return false;

	string a1 = a.substr(0, a.length()/2);
	string b1 = b.substr(0, b.length()/2);
	string a2 = a.substr(a.length()/2, a.length()/2);
	string b2 = b.substr(b.length()/2, b.length()/2);
	return (check(a1, b1) && check(a2, b2)) || (check(a1, b2) && check(a2, b1));
}

int main() {
	string a,b;
	cin >> a >> b;
	cout << (check(a,b) ? "YES" : "NO");

	return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
int get(int l,int r,int s,int e)
{
   // cout<<l<<"  "<<r<<"    "<<s<<"  "<<e<<endl;
    if(a.substr(l,r-l+1)==b.substr(s,e-s+1))return 1;
    if((r-l+1)%2)return 0;
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    return (v|k);
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    return mem[{{l,r},{s,e}}]=(v|k);
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return 1;
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return 1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    if((r-l+1)%2)return 0;
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return 1;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return 1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&&get(m1+1,r,m2+1,e);
    int k=get(l,m1,m2+1,e)&&get(m1+1,r,s,m2);
    return mem[{{l,r},{s,e}}]=(v|k);
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return mem[{{l,r},{s,e}}]=1;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return mem[{{l,r},{s,e}}]=1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return mem[{{l,r},{s,e}}]=0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
int get(int l,int r,int s,int e)
{
   // cout<<l<<"  "<<r<<"    "<<s<<"  "<<e<<endl;
    if(a.substr(l,r-l+1)==b.substr(s,e-s+1))return 1;
    if((r-l+1)%2)return 0;
    int m1=(r+l)/2,m2=(e+s)/2;
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    return k;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return (v|k);
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
   // cout<<l<<"  "<<r<<"    "<<s<<"  "<<e<<endl;
    if(a.substr(l,r-l+1)==b.substr(s,e-s+1))return 1;
    if((r-l+1)%2)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    return mem[{{l,r},{s,e}}]=(v|k);
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    if((r-l+1)%2)return 0;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A!=B)return 0;
    int m1=(r+l)/2,m2=(e+s)/2;
    int k=get(l,m1,m2+1,e)&&get(m1+1,r,s,m2);
    if(k)return 1;
    int v=get(l,m1,s,m2)&&get(m1+1,r,m2+1,e);
    if(v)return 1;
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return mem[{{l,r},{s,e}}]=1;
    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return mem[{{l,r},{s,e}}]=1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return mem[{{l,r},{s,e}}]=0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    if((r-l+1)%2)return 0;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return 1;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return 1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    if((r-l+1)%2)return 0;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A!=B)return 0;
    if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&&get(m1+1,r,s,m2);
    if(k)return mem[{{l,r},{s,e}}]=1;
    int v=get(l,m1,s,m2)&&get(m1+1,r,m2+1,e);
    if(v)return mem[{{l,r},{s,e}}]=1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return mem[{{l,r},{s,e}}]=0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    if((r-l+1)%2)return 0;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&&get(m1+1,r,s,m2);
    if(k)return 1;
    int v=get(l,m1,s,m2)&&get(m1+1,r,m2+1,e);
    if(v)return 1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


#pragma GCC optimize("O3")
#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;

const int N=50000,M=1000000;
const double EPS= 1e-9;

int n;
string a,b;
map<pair<pair<int,int>,pair<int,int>>,int>mem;
int get(int l,int r,int s,int e)
{
    string A=a.substr(l,r-l+1);
    string B=b.substr(s,e-s+1);
    if(A==B)return 1;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if((r-l+1)%2)return 0;
    if(A!=B)return 0;
   // if(mem.count({{l,r},{s,e}}))return mem[{{l,r},{s,e}}];
    int m1=(r+l)/2,m2=(e+s)/2;

    int k=get(l,m1,m2+1,e)&get(m1+1,r,s,m2);
    if(k)return 1;
    int v=get(l,m1,s,m2)&get(m1+1,r,m2+1,e);
    if(v)return 1;
  //  return mem[{{l,r},{s,e}}]=(v|k);
    return 0;
}

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
//__builtin_popcount()
input;
cin>>a>>b;
n=a.size();
if(get(0,n-1,0,n-1))cout<<"YES";
else cout<<"NO";
return 0;
}


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

typedef vector<vector<int>>matrice;

string a, b;

string findMin(string s) {
    if(s.size() == 1)
        return s;
    int m = s.size() / 2;
    string a = s.substr(0, m);
    string b = s.substr(m, m);
    a = findMin(a);
    b = findMin(b);
    if(a < b)
        return a + b;
    return b + a;
}
int main() {
    cin >> a >> b;
    if(a == b) {
        cout << "YES\n";
        return 0;
    }
    int la = a.size();
    la &= la - 1;
    if(la != 0) {
        cout << "NO\n";
        return 0;
    }
    a = findMin(a);
    b = findMin(b);

    if(a == b) cout << "YES";
    else cout << "NO";
}


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

typedef vector<vector<int>>matrice;

string a, b;

string findMin(string s) {
    if(s.size() == 1)
        return s;
    int m = s.size() / 2;
    string a = s.substr(0, m);
    string b = s.substr(m, m);
    a = findMin(a);
    b = findMin(b);
    if(a < b)
        return a + b;
    return b + a;
}
int main() {
    cin >> a >> b;
    a = findMin(a);
    b = findMin(b);
    if(a == b) cout << "YES";
    else cout << "NO";
}


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

typedef vector<vector<int>>matrice;

string a, b;

string findMin(string s) {
    if(s.size() % 2 == 1)
        return s;
    int m = s.size() / 2;
    string a = s.substr(0, m);
    string b = s.substr(m, m);
    a = findMin(a);
    b = findMin(b);
    if(a < b)
        return a + b;
    return b + a;
}
int main() {
    cin >> a >> b;
    if(a == b) {
        cout << "YES\n";
        return 0;
    }

    a = findMin(a);
    b = findMin(b);

    if(a == b) cout << "YES";
    else cout << "NO";
}


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

typedef vector<vector<int>>matrice;

string a, b;

string findMin(string s) {
    if(s.size() == 1)
        return s;
    int m = s.size() / 2;
    string a = s.substr(0, m);
    string b = s.substr(m, m);
    a = findMin(a);
    b = findMin(b);
    if(a < b)
        return a + b;
    return b + a;
}
int main() {
    cin >> a >> b;
    if(a == b) {
        cout << "YES\n";
        return 0;
    }
    int la = a.size();
    la &= la - 1;
    if(la != 0) {
        cout << "NO\n";
        return 0;
    }
    a = findMin(a);
    b = findMin(b);
    cout<<a<<endl;
    if(a == b) cout << "YES";
    else cout << "NO";
}


#include <iostream>

using namespace std;

string is(string s1){

    if(s1.length() & 1) return s1;

    string ss1=is( s1.substr(0, s1.length()/2) ), ss2=is(s1.substr(s1.length()/2, s1.length()/2));

    return ss1 > ss2 ? ss2 + ss1 : ss1 + ss2;

}

string s1, s2;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> s1 >> s2;

    if(is(s1) == is(s2)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


#include <iostream>

using namespace std;

string is(string s1){

    if(s1.length() & 1) return s1;

    string ss1=is( s1.substr(0, s1.length()/2) ), ss2=is(s1.substr(s1.length()/2, s1.length()/2));

    return ss1 < ss2 ? ss2 + ss1 : ss1 + ss2;

}

string s1, s2;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> s1 >> s2;

    if(is(s1) == is(s2)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


#include <iostream>

using namespace std;

bool is(string s1, string s2){

    if(s1 == s2) return true;
    if(s1.length() == 1) return s1==s2;

    string ss1=s1.substr(0, s1.length()/2), ss2=s1.substr(s1.length()/2, s1.length()/2);
    string ss3=s2.substr(0, s2.length()/2), ss4=s2.substr(s2.length()/2, s2.length()/2);

    return (is(ss1, ss3) & is(ss2, ss4)) | (is(ss1, ss4) & is(ss2, ss3));

}

string s1, s2;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> s1 >> s2;

    if(s1.length()&1){
        if(s1 == s2){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    }

    if(is(s1, s2)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


#include <iostream>

using namespace std;

bool is(string s1, string s2){

    if(s1 == s2) return true;
    if(s1.length() & 1) return s1==s2;

    string ss1=s1.substr(0, s1.length()/2), ss2=s1.substr(s1.length()/2, s1.length()/2);
    string ss3=s2.substr(0, s2.length()/2), ss4=s2.substr(s2.length()/2, s2.length()/2);

    return (is(ss1, ss3) & is(ss2, ss4)) | (is(ss1, ss4) & is(ss2, ss3));

}

string s1, s2;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> s1 >> s2;

    if(is(s1, s2)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
map<pair<string,string>,int> m;
bool solve(string s1,string s2)
{
	//trace2(s1,s2);
	int n=s1.length();
	if(n==1)
		return (s1==s2);
	int ans;
	if(s1==s2)
		ans=1;
	else
	{
		if(n&1)
			ans=0;
		else
		{
			string s11=s1.substr(0,n/2);
			string s12=s1.substr(n/2);
			string s21=s2.substr(0,n/2);
			string s22=s2.substr(n/2);
			ans|=(solve(s11,s21)&solve(s12,s22));
			ans|=(solve(s11,s21)&solve(s12,s22));
		}
	}
	return ans;
}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
map<pair<string,string>,int> m;
bool solve(string s1,string s2)
{
	//trace2(s1,s2);
	int n=s1.length();
	if(n==1)
		return (s1==s2);
	int ans;
	if(m.find(mp(s1,s2))!=m.end())
		return m[mp(s1,s2)];
	if(m.find(mp(s2,s1))!=m.end())
		return m[mp(s2,s1)];
	if(s1==s2)
		ans=1;
	else
	{
		if(n&1)
			ans=0;
		else
		{
			string s11=s1.substr(0,n/2);
			string s12=s1.substr(n/2);
			string s21=s2.substr(0,n/2);
			string s22=s2.substr(n/2);
			ans|=(solve(s11,s21)&solve(s12,s22));
			ans|=(solve(s11,s21)&solve(s12,s22));
		}
	}
	return m[mp(s1,s2)]=ans;
}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
map<pair<string,string>,int> m;
bool solve(string s1,string s2)
{
	//trace2(s1,s2);
	int n=s1.length();
	if(n==1)
		return (s1==s2);
	int ans;
	if(s1==s2)
		ans=1;
	if(m.find(mp(s1,s2))!=m.end())
		return m[mp(s1,s2)];
	if(m.find(mp(s2,s1))!=m.end())
		return m[mp(s2,s1)];
	else
	{
		if(n&1)
			ans=1;
		else
		{
			string s11=s1.substr(0,n/2);
			string s12=s1.substr(n/2);
			string s21=s2.substr(0,n/2);
			string s22=s2.substr(n/2);
			ans|=(solve(s11,s21)&solve(s12,s22));
			ans|=(solve(s11,s21)&solve(s12,s22));
		}
	}
	return m[mp(s1,s2)]=ans;
}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
string s1,s2;
map<pair<string,string>,int> m;
bool solve(int a,int b,int c,int d)
{
	//trace2(s1,s2);
	int f=0;
	for(int i=a,j=c;i<=b;i++,j++)
		if(s1[i]!=s2[j])
			f=1;
	if(f)
		return false;
	if((b-a)%2==1)
		return 1;
	int m1 = (a + b) >> 1;
    int m2 = (c + d) >> 1;

    return (solve(a, m1, c, m2) && solve(m1 + 1, b, m2 + 1, d)) || (solve(a, m1, m2 + 1, d) && solve(m1 + 1, b, c, m2));
}

int main()
{
	cin >>s1 >> s2;
	int n=s1.length();
	if(solve(0,n-1,0,n-1))
		cout << "YES";
	else
		cout << "NO";
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
map<pair<string,string>,int> m;
bool solve(string s1,string s2)
{
	//cout << s1<<" "<<s2<<"\n";
	int n=s1.length();
	if(n==1)
		return (s1==s2);
	int ans;
	if(m.find(mp(s1,s2))!=m.end())
		return m[mp(s1,s2)];
	if(m.find(mp(s2,s1))!=m.end())
		return m[mp(s2,s1)];
	if(s1==s2)
		ans=1;
	else
	{
		if(n&1)
			ans=0;
		else
		{
			string s11=s1.substr(0,n/2);
			string s12=s1.substr(n/2);
			string s21=s2.substr(0,n/2);
			string s22=s2.substr(n/2);
			ans|=(solve(s11,s21)&solve(s12,s22));
			ans|=(solve(s11,s22)&solve(s12,s21));
		}
	}
	return m[mp(s1,s2)]=ans;
}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
string s1,s2;
map<pair<string,string>,int> m;
bool solve(int a,int b,int c,int d)
{
	//trace2(s1,s2);
	int f=0;
	for(int i=a,j=c;i<=b;i++,j++)
		if(s1[i]!=s2[j])
			f=1;
	if(!f)
		return true;
	if((b-a)%2==0)
		return false;
	int m1 = (a + b) >> 1;
    int m2 = (c + d) >> 1;

    return (solve(a, m1, c, m2) && solve(m1 + 1, b, m2 + 1, d)) || (solve(a, m1, m2 + 1, d) && solve(m1 + 1, b, c, m2));
}

int main()
{
	IOS;
	cin >>s1 >> s2;
	int n=s1.length();
	if(solve(0,n-1,0,n-1))
		cout << "YES";
	else
		cout << "NO";
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
string s1,s2;
map<pair<string,string>,int> m;
bool solve(int a,int b,int c,int d)
{
	//trace2(s1,s2);
	int f=0;
	for(int i=a,j=c;i<=b;i++,j++)
		if(s1[i]!=s2[j])
			f=1;
	if(!f)
		return true;
	if((b-a)%2==0)
		return false;
	int m1 = (a + b) >> 1;
    int m2 = (c + d) >> 1;

    return (solve(a, m1, c, m2) && solve(m1 + 1, b, m2 + 1, d)) || (solve(a, m1, m2 + 1, d) && solve(m1 + 1, b, c, m2));
}

int main()
{
	cin >>s1 >> s2;
	int n=s1.length();
	if(solve(0,n-1,0,n-1))
		cout << "YES";
	else
		cout << "NO";
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
map<pair<string,string>,int> m;
bool solve(string s1,string s2)
{
	//trace2(s1,s2);
	int n=s1.length();
	if(n==1)
		return (s1==s2);
	int ans;
	if(s1==s2)
		ans=1;
	else
	{
		if(n&1)
			ans=0;
		else
		{
			string s11=s1.substr(0,n/2);
			string s12=s1.substr(n/2);
			string s21=s2.substr(0,n/2);
			string s22=s2.substr(n/2);
			ans|=(solve(s11,s21)&solve(s12,s22));
			ans|=(solve(s11,s22)&solve(s12,s21));
		}
	}
	return ans;
}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 300005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;
	}
};

**************************************************/
string s1,s2;
map<pair<string,string>,int> m;
bool solve(int a,int b,int c,int d)
{
	//trace2(s1,s2);
	int f=0;
	for(int i=a,j=b;i<=c;i++,j++)
		if(s1[i]!=s2[j])
			f=1;
	if(f)
		return false;
	if((b-a)%2==1)
		return 1;
	int m1 = (a + b) >> 1;
    int m2 = (c + d) >> 1;

    return (solve(a, m1, c, m2) && solve(m1 + 1, b, m2 + 1, d)) || (solve(a, m1, m2 + 1, d) && solve(m1 + 1, b, c, m2));
}

int main()
{
	cin >>s1 >> s2;
	int n=s1.length();
	if(solve(0,n-1,0,n-1))
		cout << "YES";
	else
		cout << "NO";
}


#include <bits/stdc++.h>
using namespace std;
#define g0 get<0>
#define g1 get<1>
#define DEBUG
#ifdef DEBUG
#define dbg(var) \
  { cout << __LINE__ << ": " << #var << " = " << (var) << std : : endl; }
#else
#define dbg(var)
#endif
typedef int32_t i3;
typedef int64_t i6;
typedef uint32_t u3;
typedef uint64_t u6;
typedef double d6;
typedef vector<i6> vl;

bool eq(string& s1, string& s2) {
  if (s1 == s2) {
    return true;
  }
  if (s1.size() % 2 == 0) {
    auto len = s1.size() / 2;
    string s11 = s1.substr(0, len);
    string s12 = s1.substr(len, len);
    string s21 = s2.substr(0, len);
    string s22 = s2.substr(len, len);
    if (eq(s11, s21) && eq(s12, s22)) {
      return true;
    } else {
      return eq(s11, s22) && eq(s12, s21);
    }
  } else {
    return false;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  auto len = s1.size() / 2;
  if (eq(s1, s2)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define g0 get<0>
#define g1 get<1>
#define DEBUG
#ifdef DEBUG
#define dbg(var) \
  { cout << __LINE__ << ": " << #var << " = " << (var) << std : : endl; }
#else
#define dbg(var)
#endif
typedef int32_t i3;
typedef int64_t i6;
typedef uint32_t u3;
typedef uint64_t u6;
typedef double d6;
typedef vector<i6> vl;

bool eq(string& s1, string& s2) {
  if (s1 == s2) {
    return true;
  }
  if (s1.size() % 2 == 0) {
    auto len = s1.size() / 2;
    string s11 = s1.substr(0, len);
    string s22 = s2.substr(len, len);
    if (!eq(s11, s22)) {
      string s12 = s1.substr(len, len);
      string s21 = s2.substr(0, len);
      return eq(s12, s21);
    } else {
      return true;
    }
  } else {
    return false;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  auto len = s1.size() / 2;
  if (eq(s1, s2)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define g0 get<0>
#define g1 get<1>
#define DEBUG
#ifdef DEBUG
#define dbg(var) \
  { cout << __LINE__ << ": " << #var << " = " << (var) << std : : endl; }
#else
#define dbg(var)
#endif
typedef int32_t i3;
typedef int64_t i6;
typedef uint32_t u3;
typedef uint64_t u6;
typedef double d6;
typedef vector<i6> vl;

bool cmp(string& s1, string& s2, u6 s1s, u6 s2s, u6 len) {
  for (u6 i = 0; i < len; i++) {
    if (s1[i + s1s] != s2[i + s2s]) {
      return false;
    }
  }
  return true;
}

bool eq(string& s1, string& s2, u6 s1s, u6 s2s, u6 len) {
  if (cmp(s1, s2, s1s, s2s, len)) {
    return true;
  }
  if (len % 2 == 0) {
    auto newlen = len / 2;
    if (eq(s1, s2, s1s, s2s, newlen) &&
        eq(s1, s2, s1s + newlen, s2s + newlen, newlen)) {
      return true;
    } else {
      return eq(s1, s2, s1s, s2s + newlen, newlen) &&
             eq(s1, s2, s1s + newlen, s2s, newlen);
    }
  } else {
    return false;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  auto len = s1.size();
  if (eq(s1, s2, 0, 0, len)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}


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

string orden(string a){

    if(a.size()%2){
        return a;
    }
    else{
        string a1, a2;
        for(int i=0; i<a.size()/2; i++){
            a1.push_back(a[i]);
            a2.push_back(a[i+a.size()/2]);
        }
        priority_queue<string> chid;
        chid.push(orden(a1));
        chid.push(orden(a2));
        string res;
        res+=orden(chid.top());
        chid.pop();
        res+=orden(chid.top());
        return res;
    }
}

int main(){
    string a, b;
    cin>>a>>b;
    if(orden(a)==orden(b)) cout<<"YES\n";
    else cout<< "NO\n";
}


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

string orden(string a){

    if(a.size()%2){
        return a;
    }
    else{
        string a1, a2;
        for(int i=0; i<a.size()/2; i++){
            a1.push_back(a[i]);
            a2.push_back(a[i+a.size()/2]);
        }
        string x1=orden(a1);
        string x2=orden(a2);
        if(x2>x1){
            return x1+x2;
        }
        else return x2+x1;
    }
}

int main(){
    string a, b;
    cin>>a>>b;
    if(orden(a)==orden(b)) cout<<"YES\n";
    else cout<< "NO\n";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 2e5 + 5;

string a ,b;
string solve(int l ,int r,bool flag){

    if((l + r) % 2 == 0){
        string ret = "";
        if(flag){
            ret = a.substr(l,r-l+1);
        }else{
            ret = b.substr(l,r-l+1);
        }
        return ret;
    }
    if(l == r){
        string ret = "";

        if(flag)
            ret += a[l];
        else
            ret += b[l];
        return ret;
    }
    string ret = "";
    int m = (l + r) >> 1;

    string x =  solve(l , m,flag);
    string y =  solve(m + 1,r,flag);
    if(x < y)
        ret = ret + x + y;
    else
        ret = ret + y + x;

    return ret;
}
int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if(a.size() != b.size() || a.size() % 2 == 1)
        return cout << "NO\n",0;
    string x = solve(0,a.size()-1,1);
    string y = solve(0,b.size()-1,0);
    if(y == x)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 2e5 + 5;

string a ,b;
string solve(int l ,int r,bool flag){

    if(l == r){
        string r = "";

        if(flag)
               r += a[l];
        else
               r += b[l];
        return r;
    }
    string ret = "";
    int m = (l + r) >> 1;

    string x =  solve(l , m,flag);
    string y =  solve(m + 1,r,flag);
    if(x < y)
        ret = ret + x + y;
    else
        ret = ret + y + x;

    return ret;
}
int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if(a.size() != b.size() || a.size() % 2 == 1)
        return cout << "NO\n",0;
    string x = solve(0,a.size()-1,1);
    string y = solve(0,b.size()-1,0);
    if(y == x)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 2e5 + 5;

string a ,b;
string solve(int l ,int r,bool flag){

    if((l + r) % 2 == 0){
        string ret = "";
        if(flag){
            ret = a.substr(l,r-l+1);
        }else{
            ret = b.substr(l,r-l+1);
        }
        return ret;
    }
    if(l == r){
        string r = "";

        if(flag)
            r += a[l];
        else
            r += b[l];
        return r;
    }
    string ret = "";
    int m = (l + r) >> 1;

    string x =  solve(l , m,flag);
    string y =  solve(m + 1,r,flag);
    if(x < y)
        ret = ret + x + y;
    else
        ret = ret + y + x;

    return ret;
}
int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if(a.size() != b.size() || a.size() % 2 == 1)
        return cout << "NO\n",0;
    string x = solve(0,a.size()-1,1);
    string y = solve(0,b.size()-1,0);
    if(y == x)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 2e5 + 5;

string a ,b;
string solve(int l ,int r,bool flag){

    if((l + r) % 2 == 0){
        string r = "";
        if(flag){
            r = a.substr(l,r-l+1);
        }else
            r = b.substr(l,r-l+1);
        return r;
    }
    if(l == r){
        string r = "";

        if(flag)
               r += a[l];
        else
               r += b[l];
        return r;
    }
    string ret = "";
    int m = (l + r) >> 1;

    string x =  solve(l , m,flag);
    string y =  solve(m + 1,r,flag);
    if(x < y)
        ret = ret + x + y;
    else
        ret = ret + y + x;

    return ret;
}
int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if(a.size() != b.size() || a.size() % 2 == 1)
        return cout << "NO\n",0;
    string x = solve(0,a.size()-1,1);
    string y = solve(0,b.size()-1,0);
    if(y == x)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 2e5 + 5;

string a ,b;
string solve(int l ,int r,bool flag){

    if((l + r) % 2 == 0){
        string ret = "";
        if(flag){
            ret = a.substr(l,r-l+1);
        }else{
            ret = b.substr(l,r-l+1);
        }
        return ret;
    }
    if(l == r){
        string ret = "";

        if(flag)
            ret += a[l];
        else
            ret += b[l];
        return ret;
    }
    string ret = "";
    int m = (l + r) >> 1;

    string x =  solve(l , m,flag);
    string y =  solve(m + 1,r,flag);
    if(x < y)
        ret = ret + x + y;
    else
        ret = ret + y + x;

    return ret;
}
int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if(a == b)return cout << "YES\n",0;
    if(a.size() != b.size() || a.size() % 2 == 1)
        return cout << "NO\n",0;
    string x = solve(0,a.size()-1,1);
    string y = solve(0,b.size()-1,0);
    if(y == x)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    if(n < k)
        return 0;
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;
vector<bool> prime;

void Sieve(int n)
{
    prime = vector<bool> (n+1,true);
    //vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 5e5 + 5;
const int N = 10005;

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string a,b;
    cin >> a >> b;
    if(a==b)
    {
        cout << "YES";
        return 0;
    }
    else if(a.length()%2)
    {
        cout << "NO";
        return 0;
    }
    if(smallest(a) == smallest(b))
    {
        cout << "YES";
    }
    else
        cout << "NO";
}


#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    if(n < k)
        return 0;
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;
vector<bool> prime;

void Sieve(int n)
{
    prime = vector<bool> (n+1,true);
    //vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 5e5 + 5;
const int N = 10005;

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string a,b;
    cin >> a >> b;
    if(check(a,b))
        cout << "YES";
    else
        cout << "NO";
}


#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 4e18
#define oo 2e9+5
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define F first
#define S second
#define pll pair<ll,ll>
#define mod  1000000007
#define pi acos(-1)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
string a,b;
string solve(string s)
{ if (s.size()==1) re s;

    string x = solve(s.substr(0,s.size() / 2));
    string y = solve(s.substr(s.size() / 2));

    re min(x + y, y + x);
}
int main()
{
  yalla;
  cin>>a>>b;
   if(solve(a)==solve(b))cout<<"YES";
   else cout<<"NO";
  re 0;
}


#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 4e18
#define oo 2e9
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define F first
#define S second
#define pll pair<ll,ll>
#define mod  1000000007
#define pi acos(-1)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
///
string a,b;
int occ_a1[27],occ_a2[27];
int occ_b1[27],occ_b2[27];
int si;
int main()
{ yalla;
  cin>>a>>b,si=a.size();
  if(si%2)
  { if(a==b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  else
  { if(a==b)cout<<"YES"<<endl;
    else
    { for(int i=0;i<si/2;i++)occ_a1[a[i]-'a']++;
      for(int i=si/2;i<si;i++)occ_a2[a[i]-'a']++;

      for(int i=0;i<si/2;i++)occ_b1[b[i]-'a']++;
      for(int i=si/2;i<si;i++)occ_b2[b[i]-'a']++;
      ///
      int c1=0,c2=0,c3=0,c4=0;
      for(int i=0;i<26;i++)
      { if(occ_a1[i]==occ_b1[i])c1++;
        if(occ_a1[i]==occ_b2[i])c2++;
        if(occ_a2[i]==occ_b1[i])c3++;
        if(occ_a2[i]==occ_b2[i])c4++;
      }
      ///
      if((c1==26 &&c4==26) ||(c2==26&&c3==26) )
        cout<<"YES"<<endl;
      else
        cout<<"NO"<<endl;
    }
  }

  re 0;
}


#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 4e18
#define oo 2e9+5
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define F first
#define S second
#define pll pair<ll,ll>
#define mod  1000000007
#define pi acos(-1)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
string a,b;
string solve(string s)
{
    if (s.size()%2) re s;

    string x = solve(s.substr(0,s.size() / 2));
    string y = solve(s.substr(s.size()/ 2));

    re min(x + y, y + x);
}
int main()
{
  yalla;
  cin>>a>>b;
   if(solve(a)==solve(b))cout<<"YES";
   else cout<<"NO";
  re 0;
}


#include<stdio.h>
#include<string.h>
char s1[200005], s2[200005];
int sum[155];
int Jud(int x1, int y1, int x2, int y2)
{
	int i, len;
	for(i=1;i<=127;i++)
		sum[i] = 0;
	for(i=x1;i<=y1;i++)
		sum[s1[i]]++, sum[s2[x2+i-x1]]--;
	for(i=1;i<=127;i++)
	{
		if(sum[i])
			return 0;
	}
	for(i=x1;i<=y1;i++)
	{
		if(s1[i]!=s2[x2+i-x1])
			break;
	}
	if(i==y1+1)
		return 1;
	len = y1-x1+1;
	if(len%2)
		return 0;
	if(Jud(x1, x1+len/2-1, x2, x2+len/2-1) && Jud(x1+len/2, y1, x2+len/2, y2))
		return 1;
	if(Jud(x1, x1+len/2-1, x2+len/2, y2) && Jud(x1+len/2, y1, x2, x2+len/2-1))
		return 1;
	return 0;
}
int main(void)
{
	int n;
	scanf("%s%s", s1+1, s2+1);
	if(strlen(s1+1)!=strlen(s2+1))
		printf("NO\n");
	else
	{
		n = strlen(s1+1);
		if(Jud(1, n, 1, n))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
/*
ab
ba
*/


#include<stdio.h>
#include<string.h>
char s1[100005], s2[100005];
int sum[155];
int Jud(int x1, int y1, int x2, int y2)
{
	int i, len;
	for(i=1;i<=127;i++)
		sum[i] = 0;
	for(i=x1;i<=y1;i++)
		sum[s1[i]]++, sum[s2[x2+i-x1]]--;
	for(i=1;i<=127;i++)
	{
		if(sum[i])
			return 0;
	}
	for(i=x1;i<=y1;i++)
	{
		if(s1[i]!=s2[x2+i-x1])
			break;
	}
	if(i==y1+1)
		return 1;
	len = y1-x1+1;
	if(len%2)
		return 0;
	if(Jud(x1, x1+len/2-1, x2, x2+len/2-1) && Jud(x1+len/2, y1, x2+len/2, y2))
		return 1;
	if(Jud(x1, x1+len/2-1, x2+len/2, y2) && Jud(x1+len/2, y1, x2, x2+len/2-1))
		return 1;
	return 0;
}
int main(void)
{
	int n;
	scanf("%s%s", s1+1, s2+1);
	if(strlen(s1+1)!=strlen(s2+1))
		printf("NO\n");
	else
	{
		n = strlen(s1+1);
		if(Jud(1, n, 1, n))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
/*
ab
ba
*/


#include <bits/stdc++.h>

using namespace std;

string equivalent (string s) {
    if (s.length() % 2 == 1) return s;
    string s1 = equivalent(s.substr(0, s.size()/2));
    string s2 = equivalent(s.substr(s.size()/2, s.size()));
    if (s1 < s2) return s1 + s2;
    else return s2 + s1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s1, s2; cin >> s1 >> s2;
    if (equivalent (s1) == equivalent (s2)) cout << "YES";
    else cout << "NO";

}


#include <bits/stdc++.h>

using namespace std;

bool DFS(string s1, string s2) {
    if (s1.size()%2 == 1) {
        return s1 == s2;
    }
    if (s1 == s2) return true;
    else {
        string s11 = s1.substr(0, s1.size()/2);
        string s12 = s1.substr(s1.size()/2, s1.size());
        string s21 = s2.substr(0, s2.size()/2);
        string s22 = s2.substr(s2.size()/2, s2.size());
        return (DFS(s11, s21) && (DFS(s12, s22))) || ((DFS(s11, s22) && DFS(s12, s21)));
    }
}

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

}


#include<bits/stdc++.h>
using namespace std;
//#define re register
//#define gcd __gcd
//#define Fi first
//#define Se second
//#define mp make_pair
//#define lowbit(x) ((x)&-(x))
//typedef long long LL;
//typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
string s1,s2;
int len;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	return false;
}
int main()
{
	cin>>s1;
	cin>>s2;
	len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
bool fun(string a,string b,int len)
{
	if( a == b )
		return 1;
	string a1 = a.substr(0,len/2);
	string a2 = a.substr(len/2,len);
	string b1 = b.substr(0,len/2);
	string b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return 1;
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return 1;
	return 0;
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define re register
//#define gcd __gcd
//#define Fi first
//#define Se second
//#define mp make_pair
//#define lowbit(x) ((x)&-(x))
//typedef long long LL;
//typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
string s1,s2;
int len;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	return false;
}
int main()
{
	cin>>s1;
	cin>>s2;
	len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	return 0;
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define re register
//#define gcd __gcd
//#define Fi first
//#define Se second
//#define mp make_pair
//#define lowbit(x) ((x)&-(x))
//typedef long long LL;
//typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	return false;
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
string s1,s2;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	return 0;
}
int main()
{
	cin>>s1;
	cin>>s2;
	int len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#define y0 abc111qqz
#define y1 hust111qqz
#define yn hez111qqz
#define j1 cute111qqz
#define tm crazy111qqz
#define lr dying111qqz
using namespace std;
#define REP(i, n) for (int i=0;i<int(n);++i)
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x7fffffff;
const int N=2E5+7;
string a,b;
int len;

bool equal( string x,string y,int len) {
	//  cout<<"x:"<<x<<" y:"<<y<<" len:"<<len<<endl;
	if (x==y) return true;
	string x1,x2,y1,y2;
	x1 = x.substr(0,len/2);
	x2 = x.substr(len/2,len);
	y1 = y.substr(0,len/2);
	y2 = y.substr(len/2,len);
	if (len%2==0&&equal(x1,y2,len/2)&&equal(x2,y1,len/2)) {
		return true;
	}
	if (len%2==0&&equal(x1,y1,len/2)&&equal(x2,y2,len/2)) {
		return true;
	}
	return false;
}
int main() {
	cin>>a;
	cin>>b;
	len = a.length();
	if (equal(a,b,len)) {
		puts("YES");
	} else {
		puts("NO");
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5+7;
const int M = 1e6+7;
const int lim = 1e8;
//const int p = 1e9+7;
const int inf = 0x3f3f3f3f;
bool fun(string a,string b,int len)
{
	if( a == b )
		return true;
	string a1,a2,b1,b2;
	a1 = a.substr(0,len/2);
	a2 = a.substr(len/2,len);
	b1 = b.substr(0,len/2);
	b2 = b.substr(len/2,len);
	if( len % 2 == 0 && fun(a1,b1,len/2) && fun(a2,b2,len/2) )
		return true;
	if( len % 2 == 0 && fun(a1,b2,len/2) && fun(a2,b1,len/2) )
		return true;
	return 0;
}
int main()
{
	string s1,s2;
	cin>>s1;
	cin>>s2;
	int len = s1.length();
	if( fun(s1,s2,len) )
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

string smallest(string &s, int b, int e) {
    int n = e - b + 1;
    if (n & 1) return s.substr(b, n);
    string s1 = smallest(s, b, b + n/2 - 1);
    string s2 = smallest(s, b + n/2, e);
    string s3 = s1 + s2;
    string s4 = s2 + s1;
    return s3 < s4 ? s3 : s4;
    string best = s.substr(b, n) <= s1 + s2 ? s.substr(b, n) : s1 + s2;
    return best <= s2 + s1 ? best : s2 + s1;
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    string s1 = smallest(a, 0, n - 1);
    string s2 = smallest(b, 0, n - 1);
    cout << (s1 == s2 ? "YES\n" : "NO\n");
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

string smallest(string s, int b, int e) {
    int n = e - b + 1;
    if (n & 1) return s.substr(b, n);
    string s1 = smallest(s, b, b + n/2 - 1);
    string s2 = smallest(s, b + n/2, e);
    string s3 = s1 + s2;
    string s4 = s2 + s1;
    return s3 < s4 ? s3 : s4;
    string best = s.substr(b, n) <= s1 + s2 ? s.substr(b, n) : s1 + s2;
    return best <= s2 + s1 ? best : s2 + s1;
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    string s1 = smallest(a, 0, n - 1);
    string s2 = smallest(b, 0, n - 1);
    cout << (s1 == s2 ? "YES\n" : "NO\n");
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

bool ok(string &a, string &b, int b1, int e1, int b2, int e2) {
    int nels = e1 - b1 + 1;
    if (nels & 1) {
        for (int i = b1, j = b2; i <= e1; ++i, ++j) {
            if (a[i] != b[j]) return false;
        }
        return true;
    }

    return (ok(a,b,b1,b1+nels/2-1,b2,b2+nels/2-1) && ok(a,b,b1+nels/2,e1,b2+nels/2,e2)) ||
        (ok(a,b,b1,b1+nels/2-1,b2+nels/2,e2) && ok(a,b,b1+nels/2,e1,b2,b2+nels/2-1));
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    if (n & 1) {
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i]) {
                cout << "NO\n"; return;
            }
        }
        cout << "YES\n";
        return;
    }
    if ((ok(a,b,0,n/2-1,0,n/2-1) && ok(a,b,n/2,n-1,n/2,n-1)) || (ok(a,b,0,n/2-1,n/2,n-1) && ok(a,b,n/2,n-1,0,n/2-1)))
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

map<array<int, 4>, bool> dp;

bool ok(string a, string b, int b1, int e1, int b2, int e2) {
    if (dp.count({b1,e1,b2,e2})) return dp[{b1,e1,b2,e2}];
    int nels = e1 - b1 + 1;
    if (nels & 1) {
        for (int i = b1, j = b2; i <= e1; ++i, ++j) {
            if (a[i] != b[j]) return false;
        }
        return true;
    }

    dp[{b1,e1,b2,e2}] = (ok(a,b,b1,b1+nels/2-1,b2,b2+nels/2-1) && ok(a,b,b1+nels/2,e1,b2+nels/2,e2)) ||
        (ok(a,b,b1,b1+nels/2-1,b2+nels/2,e2) && ok(a,b,b1+nels/2,e1,b2,b2+nels/2-1));
    return dp[{b1,e1,b2,e2}];
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    if (n & 1) {
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i]) {
                cout << "NO\n"; return;
            }
        }
        cout << "YES\n";
        return;
    }
    if ((ok(a,b,0,n/2-1,0,n/2-1) && ok(a,b,n/2,n-1,n/2,n-1)) || (ok(a,b,0,n/2-1,n/2,n-1) && ok(a,b,n/2,n-1,0,n/2-1)))
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

bool ok(string a, string b, int b1, int e1, int b2, int e2) {
    int nels = e1 - b1 + 1;
    if (nels & 1) {
        for (int i = b1, j = b2; i <= e1; ++i, ++j) {
            if (a[i] != b[j]) return false;
        }
        return true;
    }

    return (ok(a,b,b1,b1+nels/2-1,b2,b2+nels/2-1) && ok(a,b,b1+nels/2,e1,b2+nels/2,e2)) ||
        (ok(a,b,b1,b1+nels/2-1,b2+nels/2,e2) && ok(a,b,b1+nels/2,e1,b2,b2+nels/2-1));
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    if (n & 1) {
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i]) {
                cout << "NO\n"; return;
            }
        }
        cout << "YES\n";
        return;
    }
    if ((ok(a,b,0,n/2-1,0,n/2-1) && ok(a,b,n/2,n-1,n/2,n-1)) || (ok(a,b,0,n/2-1,n/2,n-1) && ok(a,b,n/2,n-1,0,n/2-1)))
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

bool ok(string &a, string &b, int b1, int e1, int b2, int e2) {
    int nels = e1 - b1 + 1;
    bool eq = true;
    for (int i = b1, j = b2; i <= e1; ++i, ++j) {
        if (a[i] != b[j]) { eq = false; break; }
    }
    if (eq) return true;
    if (nels&1) return false;

    return (ok(a,b,b1,b1+nels/2-1,b2,b2+nels/2-1) && ok(a,b,b1+nels/2,e1,b2+nels/2,e2)) ||
        (ok(a,b,b1,b1+nels/2-1,b2+nels/2,e2) && ok(a,b,b1+nels/2,e1,b2,b2+nels/2-1));
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    bool eq = true;
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            eq = false; break;
        }
    }
    if (eq) {
        cout << "YES\n";
        return;
    }
    if (n&1) { cout << "NO\n"; return; }

    if ((ok(a,b,0,n/2-1,0,n/2-1) && ok(a,b,n/2,n-1,n/2,n-1)) || (ok(a,b,0,n/2-1,n/2,n-1) && ok(a,b,n/2,n-1,0,n/2-1)))
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

string smallest(string s, int b, int e) {
    int n = e - b + 1;
    if (n & 1) return s.substr(b, n);
    string s1 = smallest(s, b, b + n/2 - 1);
    string s2 = smallest(s, b + n/2, e);
    string best = s.substr(b, n) <= s1 + s2 ? s.substr(b, n) : s1 + s2;
    return best <= s2 + s1 ? best : s2 + s1;
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    string s1 = smallest(a, 0, n - 1);
    string s2 = smallest(b, 0, n - 1);
    cout << (s1 == s2 ? "YES\n" : "NO\n");
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

bool ok(string a, string b, int b1, int e1, int b2, int e2) {
    int nels = e1 - b1 + 1;
    bool eq = true;
    for (int i = b1, j = b2; i <= e1; ++i, ++j) {
        if (a[i] != b[j]) { eq = false; break; }
    }
    if (eq) return true;
    if (nels&1) return false;

    return (ok(a,b,b1,b1+nels/2-1,b2,b2+nels/2-1) && ok(a,b,b1+nels/2,e1,b2+nels/2,e2)) ||
        (ok(a,b,b1,b1+nels/2-1,b2+nels/2,e2) && ok(a,b,b1+nels/2,e1,b2,b2+nels/2-1));
}

void work() {
    string a,b; cin>>a>>b;
    int n = a.size();
    bool eq = true;
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            eq = false; break;
        }
    }
    if (eq) {
        cout << "YES\n";
        return;
    }
    if (n&1) { cout << "NO\n"; return; }

    if ((ok(a,b,0,n/2-1,0,n/2-1) && ok(a,b,n/2,n-1,n/2,n-1)) || (ok(a,b,0,n/2-1,n/2,n-1) && ok(a,b,n/2,n-1,0,n/2-1)))
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define fer(i, a, n) for( int i = a; i <= n; i++)
using namespace std;
string s1, s2;
int cnt1[26][200000];
int cnt2[26][200000];
bool cntalb(int l1, int r1, int l2, int r2) {
	int count1, count2;
	int n = r1 - l1 + 1;
	if (n > 26) {
		fer(a, 0, 25) {
			count1 = cnt1[a][r1] - cnt1[a][l1] + (s1[l1] == 'a' + a);
			count2 = cnt2[a][r2] - cnt2[a][l2] + (s2[l2] == 'a' + a);
			if (count2 != count1)
				return false;
		}
	}
	else {
		fer(i, l1, r1) {
			int ch = s1[i] - 'a';
			count1 = cnt1[s1[i] - 'a'][r1] - cnt1[s1[i] - 'a'][l1] + (s1[l1] == s1[i]);
			count2 = cnt2[s1[i] - 'a'][r2] - cnt2[s1[i] - 'a'][l2] + (s2[l2] == 'a' + ch);
			if (count2 != count1)
				return false;
		}
	}
	return true;
}
bool same(int l1, int r1, int l2, int r2) {
	int sz = r1 - l1 + 1;
	if (r2 - l2 + 1 != sz) return false;
	fer(i, 0, sz - 1) {
		if (s1[l1 + i] != s2[l2 + i])
			return false;
	}
	return true;
}

bool func(int l1, int r1, int l2, int r2) {
	int n = r1 - l1 + 1;
	if (cntalb(l1, r1, l2, r2)) {
		bool b = same(l1, r1, l2, r2);
		if (b | (n & 1)) {
			return b;
		}
		bool res = false;
		res |= func(l1, l1 + n / 2 - 1, l2, l2 + n / 2 - 1) && func(l1 + n / 2, r1, l2 + n / 2, r2);
		// if (!res)
		res |= func(l1, l1 + n / 2 - 1, l2 + n / 2, r2) && func(l1 + n / 2, r1, l2, l2 + n / 2 - 1);
		return res;
	}
	return false;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif
	cin >> s1 >> s2;
	int n = s1.size();
	if (s2.size() != n) {
		cout << "NO";
		return 0;
	}
	cnt1[s1[0] - 'a'][0]++;
	cnt2[s2[0] - 'a'][0]++;
	fer(i, 1, n - 1) {
		fer(ch, 0, 25) {
			cnt1[ch][i] = cnt1[ch][i - 1] + (s1[i] == 'a' + ch);
			cnt2[ch][i] = cnt2[ch][i - 1] + (s2[i] == 'a' + ch);
		}
	}
	if (n & 1) {
		if (s1 == s2)
			cout << "YES";
		else
			cout << "NO";
		return 0;
	}
	if (func(0, n - 1, 0, n - 1))
		cout << "YES";
	else
		cout << "NO";
	return 0;
}