#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
bool ans(string s,string t)
{
	int z=s.size();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	int z1=z/2;
	g1=s.substr(0,z1);
	g2=t.substr(z1,z1);
	g3=t.substr(0,z1);
	g4=s.substr(z1,z1);
	return((ans(g1,g3)&&ans(g4,g2))||(ans(g4,g3)&&ans(g1,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	//int k=0;
	cin>>a>>b;

	//cout<<k;
	if(ans(a,b))
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
bool ans(string s,string t)
{
	int mid,x=0,y=0,l=0,k=0,z=s.size();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	g1=s.substr(0,z/2);
	g2=t.substr(z/2,z/2);
	g3=t.substr(0,z/2);
	g4=s.substr(z/2,z/2);
	x=ans(g1,g3);
	y=ans(g1,g2);
	l=ans(g4,g3);
	k=ans(g4,g2);
	return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	int k=0;
	cin>>a>>b;
	k=ans(a,b);
	//cout<<k;
	if(k)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
int ans(string s,string t)
{
	int mid,x=0,y=0,l=0,k=0;
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((s.size())%2==1||t.size()%2==1)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	g1.clear();
	g2.clear();g3.clear();g4.clear();
	g1=substring(s,0,s.size()/2);
	g2=substring(t,t.size()/2,t.size());
	g3=substring(t,0,t.size()/2);
	g4=substring(s,s.size()/2,s.size());
	x=ans(g1,g3);
	y=ans(g1,g2);
	l=ans(g4,g3);
	k=ans(g4,g2);
	//cout<<x<<" "<<y<<" "<<l<<" "<<k<<endl;
	return ((x*k)+(l*y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	int k=0;
	cin>>a>>b;
	k=ans(a,b);
	//cout<<k;
	if(k)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b;
int m,n,y;
/*string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}*/
bool ans(string s,string t)
{

	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((s.length())%2)
	{
		return 0;
	}
	//string g1,g2,g3,g4;
	int z1=s.length()/2;
	string g1=s.substr(0,z1), g2=t.substr(z1,z1),g3=t.substr(0,z1),g4=s.substr(z1,z1);
	return((ans(g1,g2)&&ans(g3,g4))||(ans(g1,g3)&&ans(g4,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	//int k=0;
	ios::sync_with_stdio(false);
	cin>>a>>b;

	//cout<<k;
	if(ans(a,b))
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b,x;
int m,n,y;
string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}
int ans(string s,string t)
{
	int mid,x=0,y=0,l=0,k=0,z=s.size();
	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((z)%2==1)
	{
		return 0;
	}
	string g1,g2,g3,g4;
	g1.clear();
	g2.clear();g3.clear();g4.clear();
	g1=substring(s,0,z/2);
	g2=substring(t,z/2,z);
	g3=substring(t,0,z/2);
	g4=substring(s,z/2,z);
	x=ans(g1,g3);
	y=ans(g1,g2);
	l=ans(g4,g3);
	k=ans(g4,g2);
	//cout<<x<<" "<<y<<" "<<l<<" "<<k<<endl;
	return ((x*k)+(l*y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	int k=0;
	cin>>a>>b;
	k=ans(a,b);
	//cout<<k;
	if(k)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
string a,b;
int m,n,y;
/*string substring(string s,int st,int en)
{
	x="";
	int j=0,i;
	for(i=st;i<en;i++)
	{
		x+=s[i];
		//cout<<x[j];
		//j++;
	}
	//x[j++]=0;
	//cout<<j<<endl;
	//cout<<x.size()<<endl<<x;

	return x;
}*/
bool ans(string s,string t)
{

	//cout<<s<<endl;//<<t<<endl;
	if(s==t)
		return 1;
	if((s.size())%2)
	{
		return 0;
	}
	//string g1,g2,g3,g4;
	int z1=s.size()/2;
	string g1=s.substr(0,z1), g2=t.substr(z1,z1),g3=t.substr(0,z1),g4=s.substr(z1,z1);
	return((ans(g1,g3)&&ans(g4,g2))||(ans(g4,g3)&&ans(g1,g2)));
	//return ((x&&k)||(l&&y));
}
	//x=ans(s.substring(0,s.size()),t.substring(0,t.size()));
int main()
{
	//int k=0;
	cin>>a>>b;

	//cout<<k;
	if(ans(a,b))
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0){
		for(int i=0;i<size;i++){
			if(a[sa+i]!=b[sb+i]){
				return 0;
			}
			return 1;
		}
	}
	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

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

	if(length%2==0){
		if(check(0,length/2,length/2)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		if(a==b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0) return a.substr(sa,size)==b.substr(sb,size);

	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

int main() {
	io();
	cin>>a>>b;
	//getline(cin,a);
	//getline(cin,b);
	int length=a.size();

	if(check(0,0,length)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0){
		return a.substr(sa,size)==b.substr(sb,size);
	}
	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

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

	if(length%2==0){
		if(check(0,length/2,length/2)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		if(a==b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	//if(size%2!=0) return a.substr(sa,size)==b.substr(sb,size);
	if(size%2==0){
		for(int i=0;i<size;i++){
			if(a[sa+i]!=b[sb+i]) return 0;
		}
		return 1;
	}

	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

int main() {
	io();
	cin>>a>>b;
	//getline(cin,a);
	//getline(cin,b);
	int length=a.size();

	if(check(0,0,length)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	//if(size%2!=0) return a.substr(sa,size)==b.substr(sb,size);
	if(size%2!=0){
		for(int i=0;i<size;i++){
			if(a[sa+i]!=b[sb+i]) return 0;
		}
		return 1;
	}

	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

int main() {
	io();
	cin>>a>>b;
	//getline(cin,a);
	//getline(cin,b);
	int length=a.size();

	if(check(0,0,length)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0){
		for(int i=0;i<size;i++){
			if(a[sa+i]!=b[sb+i]){
				return 0;
			}
			return 1;
		}
	}
	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

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

	if(a==b){
		cout<<"YES"<<endl;
	}else if(length%2==0){
		if(check(0,length/2,length/2)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0){
		return a.substr(sa,size)==b.substr(sb,size);
	}
	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

int main() {
	io();
	//cin>>a>>b;
	getline(cin,a);
	getline(cin,b);
	int length=a.size();

	if(length%2==0){
		if(check(0,length/2,length/2)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		if(a==b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

string a,b;

bool check(int sa,int sb,int size){
	if(size%2!=0){
		for(int i=0;i<size;i++){
			if(a[sa+i]!=b[sb+i]){
				return 0;
			}
		}
		return 1;
	}
	return (check(sa,sb,size/2) && check(sa+size/2,sb+size/2,size/2)) || (check(sa+size/2,sb,size/2) && check(sa,sb+size/2,size/2));
}

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

	if(length%2==0){
		if(check(0,length/2,length/2)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		if(a==b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])return 0;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff;
	if(!f)ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
/*
int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;}
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
} */
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	auto f=[&](char *s){
		int lns=ln;
		while(lns%2==0){lns>>=1;}
		for(int i=lns;i+i<ln;i<<=1){
			for(int j=0;j<ln;j+=i+i){
				for(int jj=j;jj<j+i;jj++){
					if(s[jj]>s[jj+i]){
						for(int ii=j;ii<j+i;ii++){
							swap(s[ii],s[ii+i]);
						}
					}
				}
			}
		}
	};
	f(a);f(b);
	if(strcmp(a,b)==0)printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff;
	if(!f)ff=cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
/*
int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;}
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
} */
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	auto f=[&](char *s){
		int lns=ln;
		while(lns%2==0){lns>>=1;}
		for(int i=lns;i+i<=ln;i<<=1){
			for(int j=0;j<ln;j+=i+i){
				for(int jj=j;jj<j+i;jj++){
					if(s[jj]>s[jj+i]){
						for(int ii=j;ii<j+i;ii++){
							swap(s[ii],s[ii+i]);
						}
						break;
					}
				}
			}
		}
	};
	f(a);f(b);
	if(strcmp(a,b)==0)printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
/*
int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;}
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
} */
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	auto f=[&](char *s){
		int lns=ln;
		while(lns%2==0){lns>>=1;}
		for(int i=lns;i+i<=ln;i<<=1){
			for(int j=0;j<ln;j+=i+i){
				for(int jj=j;jj<j+i;jj++){
					if(s[jj]!=s[jj+i]){
						if(s[jj]>s[jj+i])for(int ii=j;ii<j+i;ii++){
							swap(s[ii],s[ii+i]);
						}
						break;
					}
				}
			}
		}
	};
	f(a);f(b);
	if(strcmp(a,b)==0)printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])goto ff;
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(char *a,char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])return 0;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	int f=(cf313df(aa,ba,ln)&cf313df(ab,bb,ln));
	int ff=(cf313df(aa,bb,ln)&cf313df(ab,ba,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(char *a,char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])goto ff;
	}
	sort(a,a+ln);sort(b,b+ln);
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			/*string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());*/
			char aa[26]={0},bb[26]={0};
			for(int i=0;i<ln;i++)aa[a[i]-'a']++;
			for(int i=0;i<ln;i++)bb[b[i]-'a']++;
			for(int i=0;i<26;i++)if(aa[i]!=bb[i])return 0;
			break;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])goto ff;
	}
	return 1;
	ff:
	if(ln%2)return 0;
	ln/=2;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])goto ff;
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			/*string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());*/
			char aa[26]={0},bb[26]={0};
			for(int i=0;i<ln;i++)aa[a[i]-'a']++;
			for(int i=0;i<ln;i++)bb[b[i]-'a']++;
			for(int i=0;i<26;i++)if(aa[i]!=bb[i])return 0;
			break;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	//string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());
			if(a==b)break;
			else return 0;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(char *a,char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])return 0;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());
			if(aa==bb)break;
			else return 0;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff;if(!f)ff=(cf313df(aa.c_str(),bb.c_str(),ln)&&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
/*
int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;}
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
} */
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	auto f=[&](char *s){
		int lns=ln;
		while(lns%2==0){lns>>=1;}
		for(int i=lns;i+i<ln;i<<=1){
			for(int j=0;j<ln;j+=i+i){
				for(int jj=j;jj<j+i;jj++){
					if(s[jj]>s[jj+i]){
						for(int ii=j;ii<j+i;ii++){
							swap(s[ii],s[ii+i]);
						}
						break;
					}
				}
			}
		}
	};
	f(a);f(b);
	if(strcmp(a,b)==0)printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			string aa(a),bb(b);
			sort(a.begin(),a.end());
			sort(b.begin(),b.end());
			if(a==b)break;
			else return 0;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(char *a,char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	int smalla=0;
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){if(a[i]>b[i])swap(a,b);goto ff;}
	}
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){

	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])goto ff;
	}
	sort(a,a+ln);sort(b,b+ln);
	return 1;
	ff:
	if(ln&1)return 0;
	ln>>=1;
	int f=(cf313df(a,b,ln)&&cf313df(a+ln,b+ln,ln));
	int ff;if(!f)ff=(cf313df(a,b+ln,ln)&&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			/*string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());*/
			char aa[26]={0},bb[26]={0};
			for(int i=0;i<ln;i++)aa[a[i]-'a']++;
			for(int i=0;i<ln;i++)bb[b[i]-'a']++;
			for(int i=0;i<26;i++)if(aa[i]!=bb[i])return 0;
			break;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	//string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(a,b,ln)&cf313df(a+ln,b+ln,ln));
	int ff=(cf313df(a,b+ln,ln)&cf313df(a+ln,b,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(char *a,char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i])break;
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	int f=(cf313df(aa,ba,ln)&cf313df(ab,bb,ln));
	int ff=(cf313df(aa,bb,ln)&cf313df(ab,ba,ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int cf313df(const char *a,const char *b,int ln){
	//printf("%s %s\n",a,b);
	for(int i=0;i<ln;i++){
		if(a[i]!=b[i]){
			/*string aa(a),bb(b);
			sort(aa.begin(),aa.end());
			sort(bb.begin(),bb.end());*/
			char aa[26]={0},bb[26]={0};
			for(int i=0;i<ln;i++)aa[a[i]-'a']++;
			for(int i=0;i<ln;i++)bb[b[i]-'a']++;
			for(int i=0;i<26;i++)if(aa[i]!=bb[i])return 0;
			break;
			if(aa==bb)break;
			else return 0;
		}
		if(i==ln-1){return 1;}
	}
	if(ln%2)return 0;
	ln/=2;
	/*char *aa=new char[ln+1],*ab=new char[ln+1];
	aa[ln]='\0';
	strncpy(aa,a,ln);
	ab[ln]='\0';
	strncpy(ab,a+ln,ln);
	char *ba=new char[ln+1],*bb=new char[ln+1];
	ba[ln]='\0';
	strncpy(ba,b,ln);
	bb[ln]='\0';
	strncpy(bb,b+ln,ln);
	*/
	string aa(a,ln),ab(a+ln,ln),ba(b,ln),bb(b+ln,ln);
	int f=(cf313df(aa.c_str(),ba.c_str(),ln)&cf313df(ab.c_str(),bb.c_str(),ln));
	int ff=(cf313df(aa.c_str(),bb.c_str(),ln)&cf313df(ab.c_str(),ba.c_str(),ln));
	return f|ff;
}
int main(){
	char a[200001],b[200001];
	scanf("%s%s",a,b);
	int ln=strlen(a);
	if(cf313df(a,b,ln))printf("YES\n");
	else printf("NO\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

string a, b;

string smallest(string s) {
    int len = s.length();
    if(len % 2) return s;
    string a1 = smallest(s.substr(0, len/2));
    string b1 = smallest(s.substr(len/2, len));
    if(a1 < b1) return a1 + b1;
    else return b1 + a1;
}

int main() {
    cin>>a>>b;
    string k = smallest(a);
    string l = smallest(b);
    l.compare(k) ? cout<<"NO" : cout<<"YES";
    cout<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

string a, b;

bool eq(string x, string y) {
	int len = x.length();
	if(len%2) return x.compare(y) == 0;
	if(x.compare(y) == 0) return 1;
	return eq(x.substr(0, len/2), y.substr(len/2, len)) &&
		   eq(x.substr(len/2, len), y.substr(0, len/2));
}

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


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

const int max_n = 2e5 + 5;
char a[max_n], b[max_n];

bool eq(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) { equal=false; break; }
    if(equal)
        return true;
    if(n%2 == 0 && eq(a + n/2, b, n/2) && (a, b + n/2, n/2)) return true;
    if(n%2 == 0 && eq(a, b, n/2) && (a + n/2, b + n/2, n/2)) return true;
    return false;
}

int main() {
    cin>>a>>b;
    if(eq(a, b, strlen(a)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

string a, b;

bool eq(string x, string y) {
    int len = x.length();
    if(len%2) return x.compare(y) == 0;
    string a1 = x.substr(0, len/2), a2 = x.substr(len/2, len);
    string b1 = y.substr(0, len/2), b2 = y.substr(len/2, len);
    return ( eq(a1, b1) && eq(a2, b2) || eq(a1, b2) && eq(a2, b1) );
}

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


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

const int max_n = 2e5 + 5;
char a[max_n], b[max_n];

bool eq(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            equal = false;
            break;
        }
    if(equal) return true;
    if(n%2 == 0 and eq(a, b+n/2, n/2) and (a+n/2, b, n/2))
        return true;
    if(n%2 == 0 and eq(a,b, n/2) and (a + n/2, b + n/2, n/2))
        return true;
    return false;
}

bool nf(char *a, char *b, int n) {
    bool bal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            bal = false;
            break;
        }
    if(bal) return true;
    if(n % 2 == 0 and nf(a, b+n/2,n/2) and nf(a+n/2,b,n/2))
        return true;
    if(n%2 == 0 and nf(a,b,n/2) and nf(a+n/2,b+n/2,n/2))
        return true;
    return false;
}

bool f(char *a, char *b, int n) {
    bool flag = true;
    for (int i = 0; i < n; ++i)
        if (a[i] != b[i]) {
            flag = false;
            break;
        }
    if (flag) return true;
    if (n % 2 == 0 and f(a, b + n / 2, n / 2) and f(a + n / 2, b, n / 2))
            return true;
    if (n % 2 == 0 and f(a, b, n / 2) and f(a + n / 2, b + n / 2, n / 2))
            return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;
    if(nf(a, b, strlen(a)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

const int max_n = 2e5 + 5;
char a[max_n], b[max_n];

bool eq(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            equal = false;
            break;
        }
    if(equal) return true;
    if(n%2 == 0 and eq(a, b+n/2, n/2) and (a+n/2, b, n/2))
        return true;
    if(n%2 == 0 and eq(a,b,n/2) and eq(a + n/2, b + n/2, n/2))
        return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;
    if(eq(a, b, strlen(a)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

string a, b;

string smallest(string s) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int len = s.length();
    if(len % 2) return s;
    string a1 = smallest(s.substr(0, len/2));
    string b1 = smallest(s.substr(len/2, len));
    if(a1 < b1) return a1 + b1;
    else return b1 + a1;
}

int main() {
    cin>>a>>b;
    string k = smallest(a);
    string l = smallest(b);
    l.compare(k) ? cout<<"NO" : cout<<"YES";
    cout<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

const int max_n = 2e5 + 5;
char a[max_n], b[max_n];

bool eq(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            equal = false;
            break;
        }
    if(equal) return true;
    if(n%2 == 0 and eq(a, b+n/2, n/2) and (a+n/2, b, n/2))
        return true;
    if(n%2 == 0 and eq(a,b, n/2) and (a + n/2, b + n/2, n/2))
        return true;
    return false;
}

bool nf(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            equal = false;
            break;
        }
    if(equal) return true;
    if(n % 2 == 0 and nf(a, b+n/2,n/2) and nf(a+n/2,b,n/2))
        return true;
    if(n%2 == 0 and nf(a,b,n/2) and nf(a+n/2,b+n/2,n/2))
        return true;
    return false;
}

bool f(char *a, char *b, int n) {
    bool flag = true;
    for (int i = 0; i < n; ++i)
        if (a[i] != b[i]) {
            flag = false;
            break;
        }
    if (flag) return true;
    if (n % 2 == 0 and f(a, b + n / 2, n / 2) and f(a + n / 2, b, n / 2))
            return true;
    if (n % 2 == 0 and f(a, b, n / 2) and f(a + n / 2, b + n / 2, n / 2))
            return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;
    if(f(a, b, strlen(a)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define TRACE
#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)

#endif

#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define MOD(a, b)  (a < 0 ? (((a % b) + b) % b) : (a % b))

const int max_n = 2e5 + 5;
char a[max_n], b[max_n];

bool eq(char *a, char *b, int n) {
    bool equal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            equal = false;
            break;
        }
    if(equal) return true;
    if(n%2 == 0 and eq(a, b+n/2, n/2) and eq(a+n/2, b, n/2))
        return true;
    if(n%2 == 0 and eq(a,b, n/2) and eq(a + n/2, b + n/2, n/2))
        return true;
    return false;
}

bool nf(char *a, char *b, int n) {
    bool bal = true;
    for(int i = 0; i < n; ++i)
        if(a[i] != b[i]) {
            bal = false;
            break;
        }
    if(bal) return true;
    if(n % 2 == 0 and nf(a, b+n/2,n/2) and nf(a+n/2,b,n/2))
        return true;
    if(n%2 == 0 and nf(a,b,n/2) and nf(a+n/2,b+n/2,n/2))
        return true;
    return false;
}

bool f(char *a, char *b, int n) {
    bool flag = true;
    for (int i = 0; i < n; ++i)
        if (a[i] != b[i]) {
            flag = false;
            break;
        }
    if (flag) return true;
    if (n % 2 == 0 and f(a, b + n / 2, n / 2) and f(a + n / 2, b, n / 2))
            return true;
    if (n % 2 == 0 and f(a, b, n / 2) and f(a + n / 2, b + n / 2, n / 2))
            return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;
    if(eq(a, b, strlen(a)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
int main()
{
    islam();
    string a,b;
    cin>>a>>b;
    ll sz=a.size();
    sz/=2;
    if(a==b)
    {
        cout<<"YES";
        return 0;
    }
    string a1,b1,a2,b2;
    a1=a.substr(0,sz);
    a2=a.substr(sz);
    b1=b.substr(0,sz);
    b2=b.substr(sz);
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    sort(b1.begin(),b1.end());
    sort(b2.begin(),b2.end());
    if(a1==b1&&a2==b2||(a1==b2&&a2==b1))
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
int main()
{
    islam();
    string a,b;
    cin>>a>>b;
    ll sz=a.size();
    sz/=2;
    if(a==b)
    {
        cout<<"YES";
        return 0;
    }
    if(a.size()%2||a.size()!=b.size())
    {
        cout<<"NO";
        return 0;
    }
    string a1,b1,a2,b2;
    a1=a.substr(0,sz);
    a2=a.substr(sz);
    b1=b.substr(0,sz);
    b2=b.substr(sz);
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    sort(b1.begin(),b1.end());
    sort(b2.begin(),b2.end());
    if(a1==b1&&a2==b2||(a1==b2&&a2==b1))
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
bool bc(string s,string m)
{
    ll sz=s.size();
    if(s==m)
    return 1;
    if(sz%2)
        return 0;
    sz/=2;
    return(bc(s.substr(0,sz),m.substr(0,sz))&&bc(s.substr(sz),m.substr(sz)))||
    (bc(s.substr(0,sz),m.substr(sz))&&bc(s.substr(sz),m.substr(0,sz)));

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


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
bool bc(string s,string m)
{
    if(s==m)
    return 1;
    if(s.size()%2==1)
        return 0;
    return(bc(s.substr(0,s.size()/2),m.substr(0,s.size()/2))&&bc(s.substr(s.size()/2),m.substr(s.size()/2)))||
    (bc(s.substr(0,s.size()/2),m.substr(s.size()/2))&&bc(s.substr(s.size()/2),m.substr(0,s.size()/2)));

}
int main()
{
    islam();
    string a,b;
    cin>>a>>b;
        cout << (bc(a, b) ? "YES\n" : "NO\n");

    return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
bool bc(string s,string m)
{
    string a1,b1,a2,b2;
    int sz=s.size();
    if(s==m)
    return 1;
    if(sz%2)
        return 0;
    sz/=2;
    a1=s.substr(0,sz);
    a2=s.substr(sz);
    b1=m.substr(0,sz);
    b2=m.substr(sz);
    return(bc(a1,b1)&&bc(a2,b2))||(bc(a1,b2)&&bc(a2,b1));

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


#include<bits/stdc++.h>

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
bool bc(string s,string m)
{
    if(s==m)
    return true;
    int n=s.size();
    if(n%2==1)
    {
        return false;
    }

    return (bc(s.substr(0, n/2), m.substr(n/2)) &&bc(s.substr(n/2), m.substr(0, n/2)))
        || (bc(s.substr(0, n/2),m.substr(0, n/2))&&bc(s.substr(n/2), m.substr(n/2)));
}
int main()
{
    islam();
    string a,b;
    cin>>a>>b;
        cout << (bc(a, b) ? "YES\n" : "NO\n");
    return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
int main()
{
    islam();
    string a,b;
    cin>>a>>b;
    ll sz=a.size();
    sz/=2;
    if(a==b)
    {
        cout<<"YES";
        return 0;
    }
    if(a.size()%2)
    {
        cout<<"NO";
        return 0;
    }
    string a1,b1,a2,b2;
    a1=a.substr(0,sz);
    a2=a.substr(sz);
    b1=b.substr(0,sz);
    b2=b.substr(sz);
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    sort(b1.begin(),b1.end());
    sort(b2.begin(),b2.end());
    if(a1==b1&&a2==b2||(a1==b2&&a2==b1))
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";

    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
void islam()
{
    cin.tie(0);
    std::ios::sync_with_stdio(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
}
bool bc(string s,string m)
{
    if(s==m)
    return 1;
    if(s.size()%2==1)
        return 0;
    return(bc(s.substr(0,s.size()/2),m.substr(0,s.size()/2))&&bc(s.substr(s.size()/2),m.substr(s.size()/2)))||
    (bc(s.substr(0,s.size()/2),m.substr(s.size()/2))&&bc(s.substr(s.size()/2),m.substr(0,s.size()/2)));

}
int main()
{
    //islam();
    string a,b;
    cin>>a>>b;
        cout << (bc(a, b) ? "YES\n" : "NO\n");

    return 0;
}


#include<stdio.h>
int main(){
	int a, n, s, x, y, max=0, flag=0;
	scanf("%d%d", &n, &s);
	s = s*100;
	while(n--){
		scanf("%d%d", &x, &y);
		if( s >= x*100+y ){
			a = s%(x*100+y)%100;
			flag = 1;
			if( a > max )
				max = a;
		}
		if(flag)
			printf("%d", max);
		else
			printf("-1");
		return 0;
	}


#include<stdio.h>
int main()
{
    int n,s,x,y,i,d=100,e,max=0,temp=1;
    scanf("%d %d",&n,&s);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&x,&y);
        if(s>x)
        {
            temp=0;
            e=d-y;
            if(max<e && y!=0)
                max=e;
        }
        else if(s==x && y==0)
            temp=0;
    }
    if(temp==0)
        printf("%d",max);
    else
        printf("-1");
}


#include<stdio.h>
int main()
{
    int n,s,x,y,i,d=100,e,max=0,temp=1;
    scanf("%d %d",&n,&s);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&x,&y);
        if(s>=x)
        {
            temp=0;
            e=d-y;
            if(max<e && y!=0)
                max=e;
        }
    }
    if(temp==0)
        printf("%d",max);
    else
        printf("-1");
}


#include<stdio.h>
int main()
{
    int n,s,x,y,i,d=100,e,max=0,temp=1;
    scanf("%d %d",&n,&s);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&x,&y);
        if(s>x)
        {
            temp=0;
            e=d-y;
            if(max<e && y!=0)
                max=e;
        }
    }
    if(temp==0)
        printf("%d",max);
    else
        printf("-1");
}


#include<stdio.h>
int main(){

    int n,s,i,div,a,b,mod,max=-1;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(s*100 >=(a*100+b )){

           mod=100-b;
           mod=mod%100;

        if(mod >= max ){
            max=mod;}
        }

    }

    if(max==-1){
        printf("%d",-1);
    }
    else{printf("%d",max);
    }

    return 0;
}


#include<stdio.h>
int main(){

    int n,s,i,div,a,b,mod,max=-1;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(s*100 >=(a*100+b )){

           mod=100-b;

        if(mod >= max){
            max=mod;}
        }

    }

    if(max==-1){
        printf("%d",-1);
    }
    else{printf("%d",max);
    }

    return 0;
}


#include<stdio.h>
int main(){

    int n,s,i,div,a,b,mod,max=-1;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(s*100 >=(a*100+b )){

           mod=100-b;

        if(mod >= max && mod!=100){
            max=mod;}
        }

    }

    if(max==-1){
        printf("%d",-1);
    }
    else{printf("%d",max);
    }

    return 0;
}


#include <stdio.h>
int n,s,i,j,x,y,res,_max,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>x){

            res =(100- y)%100;
            k=1;
            if(res > _max) {

                _max = res;
            }
        }
        else if(s==x && y==0) k=1;
    }
    if(k==0) printf("-1");
    else  printf("%d",_max);

    return 0;
}


#include <stdio.h>
int n,s,i,j,x,y,res,_max,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>x){
            res =(100- y)%100;
            k=1;
            if(res > _max) {

                _max = res;
            }
        }
    }
    if(k==0) printf("-1");
    else  printf("%d",_max);

    return 0;
}


#include <stdio.h>
int n,s,i,j,x,y,res,_max;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>x){
            res =(100- y)%100;
            if(res > _max) _max = res;
        }
    }
    if(_max==0) printf("-1");
    else printf("%d",_max);

    return 0;
}


#include <stdio.h>
int n,s,i,j,x,y,res,_max;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>x){
            res =(100- y)%100;
            if(res > _max) _max = res;
        }
    }
    //if(_max==0) printf("-1");
     printf("%d",_max);

    return 0;
}


#include <stdio.h>
int n,s,i,j,x,y,res,_max,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>=x){
            res =(100- y)%100;
            k=1;
            if(res > _max) {

                _max = res;
            }
        }
    }
    if(k==0) printf("-1");
    else  printf("%d",_max);

    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,s,n,i,j=0,k1=0,k;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if (a>s)j++;
        else if(a<s&&b!=0){k=100-b;
        if(k>k1)k1=k;}
        // printf("%d",k1);
    }
    if(j>n)printf("0");
    else if(j<n&&k==0)printf("0");
    else if(k>0)printf("%d",k1);
    else printf("-1");
    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,s,n,i,j=0,k1=0,k;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if (a>s)j++;
        else if(a<s&&b!=0){k=100-b;
        if(k>k1)k1=k;}
        // printf("%d",k1);
    }
    if(j>n)printf("0");
    else if(k>0)printf("%d",k1);
    else printf("-1");
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,s,n,i,j=0,k1=0,k;
    scanf("%I64d %I64d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%I64d %I64d",&a,&b);
        if (a>s)j++;
        else if(a<s&&b!=0){k=100-b;
        if(k>k1)k1=k;}

    }
    if(j>n)printf("0");
    else if(j<n&&(k==0||k==100))printf("0");
    else if(k>0)printf("%I64d",k1);
    else printf("-1");
    return 0;
}


#include<stdio.h>
int main ()
{
    int n,s,a,b,c=0,i,atai_prothom=1,count=0;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if(a<s || (a<=s && b==0))
        {
            if(atai_prothom==1)
            {
                c=b;
                atai_prothom=0;
            }
            if(b!=0 && atai_prothom==0)
            {
                if(b<c)c=b;
                if(b>=c && c==0)c=b;
                if(b>=c && c!=0)c=c;
            }
        }
        else count++;
    }
    if(c==0 && count==n)printf("-1\n");
    if(c==0 && count!=n)printf("0\n");
    if(c!=0)printf("%d\n",100-c);
    return 0;
}


#include<stdio.h>
int main ()
{
    int n,s,a,b,c=0,i,atai_prothom=1;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if(a<=s-1)
        {
            if(b!=0 && atai_prothom==1)
            {
                c=b;
                atai_prothom=0;
            }
            if(b!=0 && atai_prothom==0)
            {
                if(b<c)c=b;
                if(b>=c)c=c;
            }
        }
    }
    if(c==0)printf("-1\n");
    else printf("%d\n",100-c);
    return 0;
}


#include<stdio.h>
int main ()
{
    int n,s,a,b,c=0,i,atai_prothom=1,count=0;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if(a<=s-1)
        {
            if(atai_prothom==1)
            {
                c=b;
                atai_prothom=0;
            }
            if(b!=0 && atai_prothom==0)
            {
                if(b<c)c=b;
                if(b>=c && c==0)c=b;
                if(b>=c && c!=0)c=c;
            }
        }
        else count++;
    }
    if(c==0 && count==n)printf("-1\n");
    if(c==0 && count!=n)printf("0\n");
    if(c!=0)printf("%d\n",100-c);
    return 0;
}


#include<stdio.h>
int main ()
{
    int n,s,a,b,c=0,i,atai_prothom=1;
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        if(a<=s)
        {
            if(b!=0 && atai_prothom==1)
            {
                c=b;
                atai_prothom=0;
            }
            if(b!=0 && atai_prothom==0)
            {
                if(b<c)c=b;
                if(b>=c)c=c;
            }
        }
    }
    if(c==0)printf("-1\n");
    else printf("%d\n",100-c);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct price {
    int dollor;
    int cent;
};

int comp(const void *left, const void *right)
{
    struct price *i = (struct price*)left;
    struct price *j = (struct price*)right;

    return i->cent - j->cent;
}

int main(void)
{
    int n, s;
    struct price prices[100];
    int i, j, k, l;

    memset(prices, 0, sizeof(prices));

    scanf("%d %d", &n, &s);
    for (i=0, j=0; i<n; i++) {
        scanf("%d %d", &k, &l);
        if (k > s) continue;
        if (k >= s && l > 0) continue;
        prices[j].dollor = k;
        prices[j].cent = l;
        j++;
    }

    if (j == 0) {
        printf("-1\n");
        return 0;
    }

    qsort(prices, j, sizeof(struct price), comp);

    for (i=0; i<j; i++) {
        if (prices[i].cent == 0) {
            k = 0;
            continue;
        }
        k = 100 - prices[i].cent;
        break;
    }
    printf("%d\n", k);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct price {
    int dollor;
    int cent;
};

int comp(const void *left, const void *right)
{
    struct price *i = (struct price*)left;
    struct price *j = (struct price*)right;

    return i->cent - j->cent;
}

int main(void)
{
    int n, s;
    struct price prices[100];
    int i, j, k, l;

    memset(prices, 0, sizeof(prices));

    scanf("%d %d", &n, &s);
    for (i=0, j=0; i<n; i++) {
        scanf("%d %d", &k, &l);
        if (k > s) continue;
        prices[j].dollor = k;
        prices[j].cent = l;
        j++;
    }

    if (j == 0) {
        printf("-1\n");
        return 0;
    }

    qsort(prices, j, sizeof(struct price), comp);

    printf("%d\n", (prices[0].cent == 0) ?
            0 : 100 - prices[0].cent);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct price {
    int dollor;
    int cent;
};

int comp(const void *left, const void *right)
{
    struct price *i = (struct price*)left;
    struct price *j = (struct price*)right;

    return i->cent - j->cent;
}

int main(void)
{
    int n, s;
    struct price prices[100];
    int i, j, k, l;

    memset(prices, 0, sizeof(prices));

    scanf("%d %d", &n, &s);
    for (i=0, j=0; i<n; i++) {
        scanf("%d %d", &k, &l);
        if (k > s) continue;
        prices[j].dollor = k;
        prices[j].cent = l;
        j++;
    }

    if (j == 0) {
        printf("-1\n");
        return 0;
    }

    qsort(prices, j, sizeof(struct price), comp);

    for (i=0; i<j; i++) {
        if (prices[i].cent == 0) {
            k = 0;
            continue;
        }
        k = 100 - prices[i].cent;
        break;
    }
    printf("%d\n", k);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct price {
    int dollor;
    int cent;
};

int comp(const void *left, const void *right)
{
    struct price *i = (struct price*)left;
    struct price *j = (struct price*)right;

    return i->cent - j->cent;
}

int main(void)
{
    int n, s;
    struct price prices[100];
    int i, j, k, l;

    memset(prices, 0, sizeof(prices));

    scanf("%d %d", &n, &s);
    for (i=0, j=0; i<n; i++) {
        scanf("%d %d", &k, &l);
        if (k > s) continue;
        prices[j].dollor = k;
        prices[j].cent = l;
        j++;
    }

    if (j == 0) {
        printf("-1\n");
        return 0;
    }

    qsort(prices, j, sizeof(struct price), comp);

    for (i=0; i<j; i++) {
        if (prices[i].cent == 0) {
            k = 0;
            continue;
        }
        k = prices[i].cent;
        break;
    }
    printf("%d\n", k);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct price {
    int dollor;
    int cent;
};

int comp(const void *left, const void *right)
{
    struct price *i = (struct price*)left;
    struct price *j = (struct price*)right;

    return i->cent - j->cent;
}

int main(void)
{
    int n, s;
    struct price prices[100];
    int i, j, k, l;

    memset(prices, 0, sizeof(prices));

    scanf("%d %d", &n, &s);
    for (i=0, j=0; i<n; i++) {
        scanf("%d %d", &k, &l);
        if (k > s || l == 0) continue;
        prices[j].dollor = k;
        prices[j].cent = l;
        j++;
    }

    if (j == 0) {
        printf("-1\n");
        return 0;
    }

    qsort(prices, j, sizeof(struct price), comp);

    printf("%d\n", 100 - prices[0].cent);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

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

int main(int argc, char *argv[])
{
	int i, j, k, res, sum, M, N, T, mx, mi, S, L, R;
	int price;
	scanf("%d %d", &N, &S);
	S*=100;
	res = mx = -1;
	for(i = 0; i < N; i++)
	{
		scanf("%d %d", &L, &R);
		price = L*100+R;
		while(price < S)
		{
			mx =  100 - (price % 100);
			if(mx == 100)
				mx = 0;
			if(mx > res)
			{
				res = mx;
			}
			price += L*100+R;
		}
	}

	printf("%d\n", res);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

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

int main(int argc, char *argv[])
{
	int i, j, k, res, sum, M, N, T, mx, mi, S, L, R;
	int price;
	scanf("%d %d", &N, &S);
	S*=100;
	res = mx = -1;
	for(i = 0; i < N; i++)
	{
		scanf("%d %d", &L, &R);
		price = L*100+R;
		while(price <= S)
		{
			mx =  100 - (price % 100);
			if(mx == 100)
				mx = 0;
			if(mx > res)
			{
				res = mx;
			}
			price += L*100+R;
		}
	}

	printf("%d\n", res);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

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

int main(int argc, char *argv[])
{
	int i, j, k, res, sum, M, N, T, mx, mi, S, L, R;
	int price;
	scanf("%d %d", &N, &S);
	S*=100;
	res = mx = -1;
	for(i = 0; i < N; i++)
	{
		scanf("%d %d", &L, &R);
		price = L*100+R;
		if(price <= S)
		{
			mx =  (S-price) % 100;
			if(mx == 100)
				mx = 0;
			if(mx > res)
			{
				res = mx;
			}
			price += L*100+R;
		}
	}

	printf("%d\n", res);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

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

int main(int argc, char *argv[])
{
	int i, j, k, res, sum, M, N, T, mx, mi, S, L, R;
	int price;
	scanf("%d %d", &N, &S);
	S*=100;
	res = mx = -1;
	for(i = 0; i < N; i++)
	{
		scanf("%d %d", &L, &R);
		price = L*100+R;
		while(price <= S)
		{
			mx =  (S-price) % 100;
			if(mx == 100)
				mx = 0;
			if(mx > res)
			{
				res = mx;
			}
			price += L*100+R;
		}
	}

	printf("%d\n", res);
	return 0;
}


#include <stdio.h>
#include <math.h>
int n,s,x,y,z,i,j,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>=x && y==0){
            if((100-y)>k && y>0){
                k=(100-y);
            }
        }
        else z++;
    }
    if(z==n) printf("-1");
    else printf("%d",k);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int n,s,x,y,z,i,j,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(s>=x){
            j=x;
            if((100-y)> k && y> 0){
                k=(100-y);
            }
        }
        else z++;
    }
    if(z==n) printf("-1");
    else printf("%d",k);
    return 0;
}


#include <stdio.h>
#include <math.h>
int n,s,x,y,z,i,j,k;
int main()
{
    scanf("%d %d",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(x+ceil(y/100)<s){
            j=x;
            if((100-y)> k && y> 0){
                k=(100-y);
            }
        }
        else z++;
    }
    if(z==n) printf("-1");
    else printf("%d",k);
    return 0;
}


#include<stdio.h>

int main()
{
    int n,s;

    int i,j,k,temp1,temp2,sweet,sweet1,temp3,check;

    int price[99999];

    scanf("%d %d",&n,&s);

    for(i=0;i<n;i++){
        scanf("%d %d",&temp1,&temp2);
        price[i] = temp1*100 + temp2;
    }

    check = 0;
    sweet = 0;
    for(i=0;i<n;i++){
        if(price[i]<=s*100){
            temp3 = price[i] % 100;
            if(temp3!=0){
                sweet1 = 100 -temp3;
                check = check + 1;
            }
        }
        if(check==1){
                sweet = sweet1;

        }
        else if(sweet1>sweet){
            sweet = sweet1;
        }
    }

    if(sweet==0){
        printf("%d\n",-1);
    }
    else
        printf("%d\n",sweet);
    return 0;
}


#include<stdio.h>

int main()
{
    int n,s;

    int i,j,k,temp1,temp2,sweet,sweet1,temp3,check;

    int price[99999];

    scanf("%d %d",&n,&s);

    for(i=0;i<n;i++){
        scanf("%d %d",&temp1,&temp2);
        price[i] = temp1*100 + temp2;
    }

    check = 0;
    sweet = 0;
    for(i=0;i<n;i++){
        if(price[i]<=s*100){
            temp3 = price[i] % 100;
            if(temp3!=0){
                sweet1 = 100 -temp3;
                check = check + 1;
            }
            if(check==1){
                sweet = sweet1;

            }
            else if(sweet1>sweet){
                sweet = sweet1;
            }
        }
    }

    if(sweet==0){
        printf("%d\n",-1);
    }
    else{
        printf("%d\n",sweet);
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int n,s;

    int i,j,k,temp1,temp2,sweet,sweet1,temp3,check;

    int price[99999];

    scanf("%d %d",&n,&s);

    for(i=0;i<n;i++){
        scanf("%d %d",&temp1,&temp2);
        price[i] = temp1*100 + temp2;
    }

    check = 0;
    sweet = -1;
    for(i=0;i<n;i++){
        if(price[i]<=s*100){
            temp3 = price[i] % 100;
            if(temp3==0){
                sweet1 = 0;
                check = check + 1;
            }
            else{
            sweet1 = 100 - temp3;
            check = check + 1;
            }
            if(check==1){
                sweet = sweet1;

            }
            else if(sweet1>sweet){
                sweet = sweet1;
            }
        }
    }

    if(sweet==-1){
        printf("%d\n",-1);
    }
    else{
        printf("%d\n",sweet);
    }
    return 0;
}


#include<stdio.h>

int main()
{
    float n,s;
    scanf("%f%f",&n,&s);

    float max=-1;
    float a,b;
    float i;

    for(i=1;i<=n;i++){
        scanf("%f%f",&a,&b);
        if(a+b<=s){
                b=100-b;
              if(b==100) b=0;
            if(b>max){
                max=b;
            }
        }
    }
    printf("%.0f",max);
    return 0;
}


#include<stdio.h>

int main()
{
    int n,s;
    scanf("%d%d",&n,&s);

    int max=-1;
    int a,b;
    int i;

    for(i=1;i<=n;i++){
        scanf("%d%d",&a,&b);
        if(a+b<=s){
                b=100-b;
              if(b==100) b=0;
            if(b>max){
                max=b;
            }
        }
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>

int main()
{
    int n,s;
    scanf("%d%d",&n,&s);

    int max=-1;
    int a,b;
    int i;

    for(i=1;i<=n;i++){
        scanf("%d%d",&a,&b);
        if(a+b<=s){
                b=100-b;
              if(b==0) b=0;
            if(b>max){
                max=b;
            }
        }
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>

int main()
{
    float n,s;
    scanf("%f%f",&n,&s);

    float max=-1;
    float a,b;
    float i;

    for(i=1;i<=n;i++){
        scanf("%f%f",&a,&b);
        if(a+(b/100)<=s){
                b=100-b;
              if(b==100) b=0;
            if(b>max){
                max=b;
            }
        }
    }
    printf("%.0f",max);
    return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;
	//		printf("%d\n\n",change[j-1]);
			flag=1;
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;

			flag=1;
			if(cost[i]==s)
			{
			if(cent[i]!=0)
			{
			j--;
			change[j]==0;
			flag=0;
			}
			else
			flag=1;
			}
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;
	//		printf("%d\n\n",change[j-1]);
			flag=1;
		}
	}
	int max=change[0];
	for(i=1;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;

			flag=1;
			if(cost[i]==s)
			{
			if(cent[i]!=0)
			{
			j--;
			change[j]==0;
			if(i==n-1)
			flag=1;
			else
			flag=0;
			}
			else
			flag=1;
			}
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int count=0,i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;
			count++;
			flag=1;
			if(cost[i]==s)
			{
			if(cent[i]!=0)
			{
			j--;
			change[j]==0;
			count--;
			if(i==n-1 && count!=0)
			flag=1;
			else
			flag=0;
			}
			else
			flag=1;
			}
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;
	//		printf("%d\n\n",change[j-1]);
			if(cost[i]!=s)
			flag=1;
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>

int main()
{
	int n,s;
	scanf("%d %d",&n,&s);
		int i,flag=0,j=0,cost[105],cent[105],change[105]={0};
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&cost[i],&cent[i]);
	//	printf("%d\n",cent[i]);
		if(cost[i]<=s)
		{
//		printf("%d\n",cent[i]);

			change[j]=(100-cent[i]);
			j++;
			flag=1;
			if(cost[i]==s)
			{

			if(cent[i]!=0)
			flag=0;
			else
			flag=1;
			}
		}
	}
	int max=0;
	for(i=0;i<j;i++)
	{
		if(change[i]>max && change[i]!=100)
		{
			max=change[i];
		}
	}
	if(flag==0)
		printf("-1");
	else
		printf("%d",max);
	return 0;
}


#include<stdio.h>
int main()
{
    int n,s,min1,min2,cnt,i;
    int a[105];
    int b[105];
      scanf("%d %d",&n,&s);
      for(i=0;i<n;i++)
      {
          scanf("%d %d",&a[i],&b[i]);

      }
      min1=a[0];
      min2=100;
       for(i=0;i<n;i++)
      {
          if(a[i]<min1)
            min1=a[i];
          if(b[i]<min2&&b[i]>0&&a[i]<s)
            min2=b[i];

      }
      if(min1>s)
        cnt=-1;
        else
        {
            cnt=100-min2;
        }
      printf("%d",cnt);

return 0;
}


#include<stdio.h>
int main()
{
    int n,s,min1,min2,cnt,i;
    int a[105];
    int b[105];
      scanf("%d %d",&n,&s);
      for(i=0;i<n;i++)
      {
          scanf("%d %d",&a[i],&b[i]);

      }
      min1=a[0];
      min2=100;
       for(i=0;i<n;i++)
      {
          if(a[i]<min1)
            min1=a[i];
          if(b[i]<min2&&b[i]>0)
            min2=b[i];

      }
      if(min1>s)
        cnt=-1;
        else
        {
            cnt=100-min2;
        }
      printf("%d",cnt);

return 0;
}


#include<stdio.h>
int main()
{
    int n,s,min1,min2,cnt,i;
    int a[105];
    int b[105];
      scanf("%d %d",&n,&s);
      for(i=0;i<n;i++)
      {
          scanf("%d %d",&a[i],&b[i]);

      }
      min1=a[0];
      min2=100;
       for(i=0;i<n;i++)
      {
          if(a[i]<min1)
            min1=a[i];
          if(b[i]<min2&&b[i]>0&&a[i]<s])
            min2=b[i];

      }
      if(min1>s)
        cnt=-1;
        else
        {
            cnt=100-min2;
        }
      printf("%d",cnt);

return 0;
}


#include<stdio.h>

int main(){
	int n,s,i,ans=-1,x,y;

	for(scanf("%d%d",&n,&s),i=0;i<n;i++){
		scanf("%d%d",&x,&y);

		if(x<=s){
			if(100 - y>ans) ans = 100-y;
		}
	}

	printf("%d\n",ans==100?0:ans);

	return 0;
}


#include<stdio.h>

int main(){
	int n,s,i,ans=-1,x,y;

	for(scanf("%d%d",&n,&s),i=0;i<n;i++){
		scanf("%d%d",&x,&y);

		if(x<=s && y){
			if(100 - y>ans) ans = 100-y;
		}
	}

	printf("%d\n",ans);

	return 0;
}


#include<stdio.h>

int main(){
	int n,s,i,ans=-1,x,y;

	for(scanf("%d%d",&n,&s),i=0;i<n;i++){
		scanf("%d%d",&x,&y);

		if(x<=s && y){
			if(100 - y>ans) ans = 100-y;
		}
	}

	printf("%d\n",ans<=0?-1:ans);

	return 0;
}


#include<stdio.h>

int main(){
	int n,s,i,ans=-1,x,y;

	for(scanf("%d%d",&n,&s),i=0;i<n;i++){
		scanf("%d%d",&x,&y);

		if(x<s){
			 if(y && 100-y>ans) ans = 100 - y;
			 if(!y){
			 	if(ans==-1) ans=0;
			 }
		}
		else if(x==s && y==0){
			if(ans==-1) ans = 0;
		}
	}

	printf("%d\n",ans);

	return 0;
}


#include<stdio.h>

int main(){
	int n,s,i,ans=-1,x,y;

	for(scanf("%d%d",&n,&s),i=0;i<n;i++){
		scanf("%d%d",&x,&y);

		if(x<=s && y){
			if(100 - y>ans) ans = 100-y;
		}
	}

	printf("%d\n",ans==100?-1:ans);

	return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    int n,s,a,b,c,d,ans,max;
    while(scanf("%d %d",&n,&s)!=EOF){
        max=-9999;
        d=-2;
        for(c=0;c<n;c++){
            scanf("%d %d",&a,&b);
            if(a<s){
                ans=100-b;
                if(b==0){
                    ans=0;
                }
                if(ans>max){
                    max=ans;
                }
            }
        }
        if(max>0){
        printf("%d\n",max);
        }
        else{
            printf("%d\n",-1);
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    int n,s,a,b,c,d,ans,max;
    while(scanf("%d %d",&n,&s)!=EOF){
        max=-9999;
        for(c=0;c<n;c++){
            scanf("%d %d",&a,&b);
            if(a<s){
                if(100-b>max && b!=0){
                    max=100-b;
                }
            }
        }
        if(max>0){
        printf("%d\n",max);
        }
        else{
            printf("%d\n",-1);
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    int n,s,a,b,c,d,ans,max;
    while(scanf("%d %d",&n,&s)!=EOF){
        max=-9999;
        d=-2;
        for(c=0;c<n;c++){
            scanf("%d %d",&a,&b);
            if(a<s){
                ans=100-b;
                if(b==0){
                    ans=0;
                }
                if(ans>max){
                    max=ans;
                }
            }
        }
        if(max>=0){
        printf("%d\n",max);
        }
        else{
            printf("%d\n",-1);
        }
    }
    return 0;
}