#include <fstream.h>
#include <memory.h>
#include <string.h>

unsigned char str1[512];
unsigned char str2[512];
int  cods1[256];
int  cods2[256];

int main()
{
	ifstream  in ( "ancient.in" );
	ofstream out ( "ancient.out" );

	in >> str1 >> str2;

	int l1 = strlen((char*)(str1));
	int l2 = strlen((char*)(str2));

	memset( cods1, 0, sizeof(cods1) );
	memset( cods2, 0, sizeof(cods2) );

	for (int i = 0; i < l1; i++) cods1[str1[i]]++;
	for (i = 0;     i < l2; i++) cods2[str2[i]]++;

	for (i = 0; i < 256; i++)
	{
		int max = i;
		for (int j = i+1; j < 256; j++)
		{
			if (cods1[j] > cods1[max]) max = j;
		}

		int tmp  = cods1[i];
		cods1[i] = cods1[max];
		cods1[max] = tmp;
	}
	
	for (i = 0; i < 256; i++)
	{
		int max = i;
		for (int j = i+1; j < 256; j++)
		{
			if (cods2[j] > cods2[max]) max = j;
		}

		int tmp  = cods2[i];
		cods2[i] = cods2[max];
		cods2[max] = tmp;
	}

	bool fl = true;

	for (i = 0; i < l1; i++)
	{
		if (cods1[i] != cods2[i])
		{
			fl = false;
			break;
		}
	}

	if (fl) out << "YES";
	else out << "NO";

	return 0;
}