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

using namespace std;

FILE* in=fopen("ancient.in","r");
//FILE* in=stdin;
FILE* out=fopen("ancient.out","w");
//FILE* out=stdout;
char s1[110],s2[110];
long ms1[30],ms2[30];
int main()
{
	long n1,n2,i;
	fscanf(in,"%s%s",s1,s2);
	n1=strlen(s1);
	n2=strlen(s2);
	if (n1!=n2)
	{
		fprintf(out,"NO\n");
		return 0;
	}
	for(i=0;i<26;i++)
	{
		ms1[i]=ms2[i]=0;
	}
	for(i=0;i<n1;i++)
	{
		ms1[s1[i]-'A']++;
		ms2[s2[i]-'A']++;
	}
	sort(ms1,ms1+26);
	sort(ms2,ms2+26);
	for(i=0;i<26;i++)
		if (ms1[i]!=ms2[i]) break;
	if (i<26)
		fprintf(out,"NO\n");
	else
		fprintf(out,"YES\n");
	return 0;
}