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

int	fcmp(const void * pa, const void * pb) {
	int	a=*((int *)pa);
	int	b=*((int *)pb);
	if (a>b) return 1;
	if (a<b) return -1;
	return 0;
}

int main() { 
	FILE	*FI, *FO;
	FI=fopen("ancient.in","rt");
	FO=fopen("ancient.out","wt");
	char	str1[150], str2[150];
	int		cnt1[256]={0}, cnt2[256]={0};
	int		l1, l2, i;
	fscanf(FI,"%s %s",str1, str2);
	fclose(FI);
	l1=strlen(str1);
	l2=strlen(str2);
	for (i=0; i<l1; i++) cnt1[str1[i]]++;
	for (i=0; i<l2; i++) cnt2[str2[i]]++;
	qsort(cnt1,256,sizeof(int),fcmp);
	qsort(cnt2,256,sizeof(int),fcmp);
	for (i=0; i<256; i++) 
		if (cnt1[i]!=cnt2[i]) {
			fprintf(FO,"NO\n");
			fclose(FO);
			return 0;	
		}
	fprintf(FO,"YES\n");	
	fclose(FO);
	return 0;
}