#include <stdio.h>
#include <string.h>
//extern "C" int getch();

char String1[120];
char String2[120];
char Exist[120];

int Num1[26], Num2[26];

int N1, N2;

void FileRead()
{
	FILE *input = fopen("ancient.in", "r");
	fscanf(input, "%s", &String1);
	fscanf(input, "%s", &String2);
	fclose(input);
}

void Debug()
{
	FILE *debug = fopen("debug.txt", "a+");
	fprintf(debug, "%s\n", String1);
	fclose(debug);
}

void Bubble()
{
	int i, j, temp;

	for(i=0; i<26; i++)
		for(j=0; j<25; j++)
			if( Num1[j] > Num1[j+1] )
			{
				temp = Num1[j];
				Num1[j] = Num1[j+1];
				Num1[j+1] = temp;
			}

	for(i=0; i<26; i++)
		for(j=0; j<25; j++)
			if( Num2[j] > Num2[j+1] )
			{
				temp = Num2[j];
				Num2[j] = Num2[j+1];
				Num2[j+1] = temp;
			}
}

int Equial()
{
	int i = 0;
	while( (i<26) && (Num1[i] == Num2[i])) i++;
	if( i == 26 ) return 1;
	else return 0;
}

void Count()
{
	int i;
		
	for(i=0; i<N1; i++)
	{
		Num1[i] = 0;
		Num2[i] = 0;
	}

	for(i=0; i<N1; i++)
		Num1[ String1[i]-'A' ]++;

	for(i=0; i<N2; i++)
		Num2[ String2[i]-'A' ]++;
	
}

void Move()
{
	int i;
	for(i=0; i<N1; i++)
	{
		if( String1[i] == 'Z' ) String1[i] = 'A';
		else String1[i]++;
	}
}

int Compare()
{
	int i = 0, j = 0;

	memset(Exist, 0, 120);

	for(i=0; i<N1; i++)
	{
		for(j=0; j<N2; j++)
		{
			if( (String1[i] == String2[j]) && (Exist[j] == 0) )
			{
				Exist[j] = 1;
				break;
			}
		}
		
		if( j == N2 ) 
		{
			return 0;
		}
	}
	return 1;
}

int Solution()
{

	N1 = strlen(String1);
	N2 = strlen(String2);

	//printf("%d %d", N1, N2);
	
	if( N1 != N2 ) return 0;

	Count();
	Bubble();
	if( Equial() ) return 1;
	else return 0;
}

void FileWrite()
{
	FILE *output = fopen("ancient.out", "w");
	if ( Solution() == 1 ) fprintf(output, "YES");
	else fprintf(output, "NO");
	fclose(output);
}

int main()
{
	FileRead();
	FileWrite();
	//getch();
	return 0;
}