#include <stdio.h>

int main(){
	//Input
	FILE *f=fopen("ancient.in","rt");
	char s1[200],s2[200];
	int a1[256],a2[256];
	bool ok=true;
	fscanf(f,"%s %s",s1,s2);
	fclose(f);

	//Fill arrays with 0
	for (int i=0;i<256;i++){
		a1[i]=0;a2[i]=0;
	}

	//Count letters in strings
	i=0;
	while (s1[i]){a1[s1[i]]++;i++;}
	i=0;
	while (s2[i]){a2[s2[i]]++;i++;}

	//Scan for equal counts
	for (i=0;i<256;i++) if (a1[i]){
		int j=0;
		while (a2[j]!=a1[i] && j<256) j++;
		if (j==256) {ok=false;break;}  //Not found!
		a2[j]=0;
	}

	//Test a2 on zeros
	if (!ok){
		for (i=0;i<256;i++) if (a2[i]) ok=false;
	}

	//Output
	f=fopen("ancient.out","wt");
	fprintf(f,"%s",ok?"YES":"NO");
	fclose(f);
	return 0;
}