#include<fstream.h>
#include<string.h>
char str1[1000];
char str2[1000];
char sum1[1000];
char sum2[1000];
int proc(char *src, char *dst, int n)
{
	int pos=0;
	int i,j;
	for(i=0;i<n;i++){
		if(!src[i])continue;
		char t=src[i];
		for(j=0;j<n;j++)
			if(src[j]==t){
				dst[pos]++;
				src[j]=0;
			}
		pos++;
	}
	return pos;
}
int main()
{
	ifstream in("ancient.in");
	ofstream out("ancient.out");
	in>>str1;
	in>>str2;
	int len = strlen(str1),i,j,pos;
	int len2 = strlen(str2);
	if(len!=len2){
		out<<"NO"<<endl;
		return 0;
	}
	if((pos=proc(str1,sum1,len))!=proc(str2,sum2,len)){
		out<<"NO"<<endl;
		return 0;
	}
	for(i=0;i<pos;i++){
		char notFnd=1;
		for(j=0;j<pos;j++){
			if(sum2[j]==sum1[i]){
				notFnd=0;
				sum2[j]=0;
				break;
			}
		}
		if(notFnd){
				out<<"NO"<<endl;
				return 0;
			}
	}
	for(i=0;i<pos;i++)
		if(sum2[i]){
			out<<"NO"<<endl;
			return 0;
		}
	out<<"YES"<<endl;
	return 0;
}