能分就分,且把字典序小的排前面
#include<bits/stdc++.h>
using namespace std;
string equ(string s)
{
int n=s.length();
if (n&1) return s;
string s1= equ(s.substr(0,n/2));
string s2= equ(s.substr(n/2,n/2));
if (s1<s2) return s1+s2;
return s2+s1;
}
string s1,s2;
int main()
{
cin>>s1>>s2;
if (equ(s1).compare(equ(s2))==0)
{
cout<<"YES"<<endl;
}
else cout<<"NO"<<endl;
return 0;
}