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

#include	<algorithm>
using namespace std;

int main(void)
{
	freopen("ancient.in", "r", stdin);
	freopen("ancient.out", "w", stdout);
	
	char a[10000], b[10000];
	a[0] = 0;
	b[0] = 0;

	gets(a);
	gets(b);

	int lenA = strlen(a);
	int lenB = strlen(b);

	int countA[256];
	int countB[256];

	memset(countA, 0, sizeof(countA));
	memset(countB, 0, sizeof(countB));

	int i;
	for (i = 0; i < lenA; ++i)
		++countA[(unsigned)a[i]];
	for (i = 0; i < lenB; ++i)
		++countB[(unsigned)b[i]];

	sort(countA, countA + 256);
	sort(countB, countB + 256);

	i = 0;
	while ( (i < 256) && (countA[i] == countB[i]) )
		++i;

	if (i == 256)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}