#include <stdio.h>
#include <string.h>
#define MAX 1024

char s[MAX],t[MAX];
int countL[MAX],countNS[MAX],countNT[MAX];
int permIn[MAX],permOut[MAX];

int Solve() {
	int i,n;
	scanf("%s %s", s, t);
	n = strlen(s);
	if (n != strlen(t)) return 0;
	for (i=0; i<128; i++)
		countL[i] = 0;
	for (i=0; i<n; i++)
		countL[s[i]]++;
	for (i=0; i<128; i++)
		countNS[i] = 0;
	for (i=0; i<128; i++)
		countNS[countL[i]]++;
	for (i=0; i<128; i++)
		countL[i] = 0;
	for (i=0; i<n; i++)
		countL[t[i]]++;
	for (i=0; i<128; i++)
		countNT[i] = 0;
	for (i=0; i<128; i++)
		countNT[countL[i]]++;
	for (i=0; i<128; i++)
		if (countNS[i]!=countNT[i]) return 0;

	return 1;
}

int main() {
	freopen("ancient.in", "rt", stdin);
	freopen("ancient.out", "wt", stdout);
	if (Solve())
		puts("YES");
	else
		puts("NO");
	return 0;
}