#include <string.h>
//#include <iostream.h>
#include <fstream.h>

struct elem
{
	char c;
	short ind;
};

int main()
{
	elem normal[26], coded[26], tmp;
	char *cNormal = new char[101];
	char *cCoded = new char[101];
	unsigned int i,j;
	bool 	bFlag = true;

	ifstream InFile ("ancient.in", ios::in);
	ofstream OutFile ("ancient.out", ios::out);


	for (i = 0; i < 26; i++)
	{
		normal[i].ind = 0;
		coded[i].ind = 0;

		normal[i].c = i + 65 ;
		coded[i].c = i + 65;




	}

	InFile >> cNormal >> cCoded;

	for ( i = 0; i < strlen (cNormal); i++)
	{
		normal[cNormal[i] - 65].ind++;
	}

	for ( i = 0; i < strlen (cCoded); i++)
	{
		coded[cCoded[i] - 65].ind++;
	}

	for ( i = 0 ; i< 26; i++)
	{
		for ( j = 0; j< 26; j++)
		{
			if (normal[i].ind >= normal[j].ind)
			{
				tmp = normal[i];
				normal[i] = normal[j];
				normal[j] = tmp;
			}


			if (coded[i].ind >= coded[j].ind)
			{
				tmp = coded[i];
				coded[i] = coded[j];
				coded[j] = tmp;
			}
		}
	
	}


	for (i = 0; (i < 26) && (bFlag == true); i++)
	{
		if (coded[i].ind != normal[i].ind) bFlag = false;

	}

	if ( bFlag == true ) OutFile << "Yes" << endl;
	else OutFile << "NO" << endl;

	return 0;
}