
# include <iostream.h>


# include <fstream.h>



ifstream input("ancient.in");
ofstream output("ancient.out");



int main()
{

	char a[200],b[200];
	int i,a_count,b_count;
	char temp;
	int count,at;
	int count1;
	int index;
	input>>a>>b;



	i=0;
	while(a[i]!='\0')
	i++;
	a_count=i;
	i=0;
	while(b[i]!='\0')
		i++;
	b_count=i;






	if (a_count!=b_count)
	{

		output<<"NO"<<endl;
		return 0;
	}

	if (a_count==1)
	{
		output<<"YES"<<endl;
		return 0;
	}


bool t=true;


while (t)
{
	t=false;
	for (i=0;i<a_count-1;i++)
	{
		if (a[i]>a[i+1])
		{
			temp=a[i];
			a[i]=a[i+1];
			a[i+1]=temp;
			t=true;
		}
	}
}

t=true;

while (t)
{
	t=false;
	for (i=0;i<a_count-1;i++)
	{
		if (b[i]>b[i+1])
		{
			temp=b[i];
			b[i]=b[i+1];
			b[i+1]=temp;
			t=true;
		}
	}
}




int aa[100];
int bb[100];
for (i=0;i<100;i++)
{
	aa[i]=bb[i]=0;
}


count=0;

at=a[0];
index=1;
for (i=1;i<=a_count;i++)
{
	if (a[i]==at)
	{
		index++;
		

	}
	else
	{
		aa[count]=index;
		count++;

		index=1;
		at=a[i];
	}

}


at=b[0];
index=1;
count1=0;
for (i=1;i<=a_count;i++)
{
	if (b[i]==at)
	{
		index++;
		

	}
	else
	{
		bb[count1]=index;
		count1++;

		index=1;
		at=b[i];
	}

}



if (count1!=count)
{
	output<<"NO"<<endl;
	return 0;
}

int temp1;


t=true;
while (t)
{
	t=false;
	for (i=0;i<count-1;i++)
	{
		if (bb[i]>bb[i+1])
		{
			temp1=bb[i];
			bb[i]=bb[i+1];
			bb[i+1]=temp1;
			t=true;
		}
	}
}

t=true;
while (t)
{
	t=false;
	for (i=0;i<count-1;i++)
	{
		if (aa[i]>aa[i+1])
		{
			temp1=aa[i];
			aa[i]=aa[i+1];
			aa[i+1]=temp1;
			t=true;
		}
	}
}





for (i=0;i<count;i++)
{
	if (aa[i]!=bb[i])
	{
		output<<"NO"<<endl;
		return 0;
	}
}


output<<"YES"<<endl;
return 0;
}



