#include <stdio.h>
#include <string.h>
#include <math.h>
#define truestr "YES"
#define falsestr "NO"

int arr1[30],arr2[30];
char s1[201],s2[201];

int k;
int main()
{
	int i,j;
	freopen("ancient.in","r",stdin);
	freopen("ancient.out","w",stdout);
	for (i=0;i<30;i++)
	{
		arr1[i]++;
		arr2[i]++;
	}

	scanf("%s",s1);
	scanf("%s",s2);
	for (i=0;i<strlen(s1);i++)
	{
		arr1[s1[i]-'A']++;
		arr2[s2[i]-'A']++;
	}
	for (i=0;i<30-1;i++)
	{
		for (j=29;j>i;j--)
			if (arr1[j]<arr1[j-1])
			{
				int temp=arr1[j];
				arr1[j]=arr1[j-1];
				arr1[j-1]=temp;
			}
	}
	for (i=0;i<30-1;i++)
	{
		for (j=29;j>i;j--)
			if (arr2[j]<arr2[j-1])
			{
				int temp=arr2[j];
				arr2[j]=arr2[j-1];
				arr2[j-1]=temp;
			}
	}
	for (i=0;i<30;i++)
		if (arr1[i]!=arr2[i]) {printf(falsestr); return 0;}
	printf(truestr);
	return 0;
}