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

char s1[1000], s2[1000];
int c1[1000], c2[1000];

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

int main() {
	int i;

	fclose(stdin);
	fopen("ancient.in", "r");
	fclose(stdout);
	fopen("ancient.out", "w");

	scanf("%s %s", s1, s2);
	for (i = 0; i < 1000; i++)
		c1[i] = c2[i] = 0;

	for (i = 0; s1[i] != '\0'; i++)
		c1[s1[i] - 'A']++;
	for (i = 0; s1[i] != '\0'; i++)
		c2[s2[i] - 'A']++;
	qsort(c1, 1000, sizeof(c1[0]), cmp);
	qsort(c2, 1000, sizeof(c2[0]), cmp);

	for (i = 0; i < 1000; i++)
		if (c1[i] != c2[i]) {
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
}