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

int compar(const void *a, const void *b)
{
	return (*(int *)b - *(int *)a);
}

int main()
{
	FILE *f;
	char str1[200], str2[200];
	int  kk1[256] = {0}, kk2[256] = {0};
	int  kiek1, kiek2, i, yes=1;
	char c;

	f = fopen("antient.in", "r");
	fscanf(f, "%s\n%s", str1, str2);
	fclose(f);

	f = fopen("antient.out", "w");
	if (strlen(str1) != strlen(str2)) {
		fprintf(f, "NO");
		return 0;
	}
	
	for (c = 'A'; c <= 'Z'; c++) {
		kiek1 = kiek2 = 0;
		for (i = 0; i < strlen(str1); i++) {
			if (str1[i] == (char) c) kiek1++;
			if (str2[i] == (char) c) kiek2++;
		}
		kk1[(char) c] = kiek1;
		kk2[(char) c] = kiek2;
	}

	qsort(kk1, 256, sizeof(int), compar);
	qsort(kk2, 256, sizeof(int), compar);

	for (i = 0; i < 256; i++)
		yes = yes && (kk1[i] == kk2[i]);

	/*
	fprintf(f, "%s\n%s\n", str1, str2);
	for (i = 0; i < 256; i++)
		fprintf(f, "%d ", kk1[i]);
	fprintf(f, "\n");
	for (i = 0; i < 256; i++)
		fprintf(f, "%d ", kk2[i]);
	fprintf(f, "\n");
	*/
	if (yes) fprintf(f, "YES");
		else fprintf(f, "NO");

	return 0;
}



