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

int main()
{
	FILE* in;
	FILE* out;
	int ocE[26];
	int ocO[26];
	char O[110],E[110];
	int i,len;
	double hE,hO,tmp,lg2=log(2.0);

	in = fopen("ancient.in", "rt");
	fscanf(in, "%s", E);
	fscanf(in, "%s", O);
	fclose(in);

	len=strlen(O);

	for(i=0;i<26;i++){
		ocE[i]=0;
		ocO[i]=0;
	}

	for(i=0;i<len;i++) {
		ocE[E[i]-'A']++;
		ocO[O[i]-'A']++;
	}

	hE=0.0;
	hO=0.0;
	for(i=0;i<26;i++){
		if(ocE[i]!=0) {
			tmp=ocE[i]/(double)len;
			hE+=tmp*log(tmp)/lg2;
		}
		if(ocO[i]!=0) {
			tmp=ocO[i]/(double)len;
			hO+=tmp*log(tmp)/lg2;
		}
	}

	out = fopen("ancient.out", "wt");
	hE-=hO;
	if(hE<0)
		hE=-hE;
	if(hE<=1E-7){
		fprintf(out,"YES");
	}
	else
		fprintf(out,"NO");
	fclose(out);



	return (0);
}