#include <stdio.h>

void read(FILE *f, int *Arr)
{
	int i;
	for (i=0;i<='Z'-'A';i++) Arr[i]=0;
	
	char c=0;
	while (c<'A' || c>'Z') fscanf(f,"%c",&c);
	i=1;
	while (c>='A' && i==1 && c<='Z')
	{
		Arr[c-'A']++;
		i=fscanf(f,"%c",&c);
	}
	
	for (i=0;i<='Z'-'A';i++)
		for (int j=i+1;j<='Z'-'A';j++)
		{
			if (Arr[i]<Arr[j])
			{
				int t=Arr[i];
				Arr[i]=Arr[j];
				Arr[j]=t;
			}
		}
}

int main()
{
	FILE *f=fopen("ancient.in","rt");
	int A[100], B[100];
	read(f,A);
	read(f,B);
	fclose(f);
	int yes=1;
	for (int i=0;i<='Z'-'A';i++) if (A[i]!=B[i]) yes=0;
	f=fopen("ancient.out","wt");
	if (yes)
	{
		fprintf(f,"YES");
	}
	else
	{
		fprintf(f,"NO");
	}
	fclose(f);
	return 0;
}