#include <fstream.h>
#include <math.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
const long MAX = 110;
char s1[MAX], s2[MAX];
long L1, L2, mas1[26], mas2[26];

void Input(){
	cin >> s1 >> s2;
}

int fcmp(const void* v1, const void* v2) {
	long l1 = *(long*) v1;
	long l2 = *(long*) v2;
	if (l1 < l2)
		return -1;
	if (l1 > l2)
		return 1;
	return 0;
}

void Solve(){
	L1 = strlen(s1);
	L2 = strlen(s2);
	if (L1 != L2) {
		cout << "NO";
		return;
	}
	long i;
	memset(mas1, 0, sizeof mas1);
	memset(mas2, 0, sizeof mas2);
	for (i = 0; i < L1; i++) 
		mas1[s1[i] - 'A']++;
	for (i = 0; i < L2; i++) 
		mas2[s2[i] - 'A']++;
	qsort(mas1, 26, sizeof mas1[0], fcmp);
	qsort(mas2, 26, sizeof mas2[0], fcmp);
	long od = 1;
	for (i = 0; i < 26; i++)
		if (mas1[i] != mas2[i])
			od = 0;
	if (od)
		cout << "YES";
	else
		cout << "NO";
}

void Output(){
}

int main(){
	ifstream fi("ancient.in");
	ofstream fo("ancient.out");
	cin = fi;
	cout = fo;
	Input();
	Solve();
	Output();
	return 0;
}