#include <stdio.h>
#include <algorithm>

int comp1(char* a, char* b)
{
	int c[27], d[27], i;
	for(i=0; i<27; i++)d[i] = c[i]=0;
	while(*a)c[*(a++)-'A']++;
	while(*b)d[*(b++)-'A']++;
	std::sort(c, c+27);
	std::sort(d, d+27);
	for(i=0; i<27; i++)if(c[i] - d[i] != 0)return 0;	
	return 1;
}
void cop(char* a, char* b)
{
	int i;
	for(i=0; a[i]; i++)if(a[i] != 'Z')b[i] = a[i]+1;else a[i] = 'A';
	b[i] = 0;
}
int main()
{
	FILE *in, *out;
	in = fopen("ancient.in", "rt");
	char buf1[101], buf2[101];
	fscanf(in, "%s%s", buf2, buf1);
	fclose(in);

	bool res = false;
	if(comp1(buf1, buf2))res = 1;
	out = fopen("ancient.out", "wt");
	if(res)fprintf(out, "YES");
	else fprintf(out, "NO");
	fclose(out);
	return 0;
}