// b.cpp : Defines the entry point for the console application.
//

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

using namespace std;

int s1[100], s2[100];

void test(char *arg1, bool *arg2, int l)
{
	int i,j;
	char c;
	bool t;
	for (i=0; i<l; i++) 
	{
		c = arg1[i];
		arg2[i] = true;
		s1[i] = 1;
		t = false;
		for (j=0; j<l; j++) 
		{
			if ((arg1[j] == c)&&(!arg2[j]))
			{
				s1[i]++;
				arg2[j] = true;
				t = true;
			}
		}
		if (!t) arg2[i] = false;
		
	}
}

void test2(char *arg1, bool *arg2, int l)
{
	int i,j;
	char c;
	bool t;
	for (i=0; i<l; i++) 
	{
		c = arg1[i];
		arg2[i] = true;
		s2[i] = 1;
		t = false;
		for (j=0; j<l; j++) 
		{
			if ((arg1[j] == c)&&(!arg2[j]))
			{
				s2[i]++;
				arg2[j] = true;
				t = true;
			}
		}
		if (!t) arg2[i] = false;
	}
}



void ssort(int *fss, int l)
{
	int i, j, k = 0;
	int smin;
	
	for (i=0; i<l; i++)
	{
		k = i;
		smin = fss[i];
		for (j=i+1; j<l; j++)
		{
			if (smin<fss[j]) 
			{
				smin=fss[j];
				k = j;
			}
		}
				fss[k] = fss[i]; 
				fss[i] = smin; 
	}
}

int main(int argc, char* argv[])
{
	FILE *in;
	FILE *out;
	
	int k, as1,as2 = 0;
	unsigned int s;
	
	char a[100], b[100], c;
	bool ok[100], ok1[100], sd;
	
	in=fopen("ancient.in", "r");
	out=fopen("ancient.out", "w");
	
	fscanf(in, "%s", a);
	fscanf(in, "%s", b);
	
	s = strlen(b);
	
	for (k=0; k<s; k++){ ok[k] = false; ok1[k] = false;}
	
	test(a,ok,s);	
	test2(b,ok1,s);
	
	ssort(s1, s);
	ssort(s2, s);

/*	for (as1=0; as1<s; as1++) fprintf(out, "%d\n", s1[as1]);
	fprintf(out, "huy\n");
	for (as1=0; as1<s; as1++) fprintf(out, "%d\n", s2[as1]);
*/
	sd = false;
	for (as1=0; as1<s; as1++)
	{
		if (s1[as1]==s2[as1]) as2++;
	}
	
	if (as2==s) fprintf(out, "YES"); else fprintf(out, "NO");

	return 0;
}

