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

int Compare(const void *a, const void *b){
	int *c1 = (int *) a, *c2 = (int *) b;
	if (*c1 > *c2) return 1;
	else if (*c1 < *c2) return -1;
	else return 1;
}

int main(){
	char str[101], ens[101];
	int len, temp1[26], temp2[26], i;
	freopen("ancient.in", "r", stdin);
	freopen("ancient.out", "w", stdout);
	str[0] = ens[0] = '\0';
	scanf("%s\n%s\n", ens, str);
	len = strlen(str);
	if (len == 0) {
		return 0;
	}
	for (i=0; i<26; i++) temp1[i] = temp2[i] = 0;
	for (i=0 ;i<len ;i++) {
		temp1[str[i] - 'A']++;
		temp2[ens[i] - 'A']++;
	}
	qsort(temp1, 26, sizeof(int), Compare);
	qsort(temp2, 26, sizeof(int), Compare);
	for (i=0; i<26; i++) {
		if (temp1[i] != temp2[i]) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}