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

int pIntCmp(const void *p1, const void *p2)
{
	return *((int*) p1) - *((int*) p2);
}

int A1[12345], A2[12345];
char s1[12345], s2[12345];
int i, l;

int main()
{
	freopen("ancient.in", "r", stdin);
	freopen("ancient.out", "w", stdout);

	gets(s1);
	gets(s2);

	if ( strlen(s1) != strlen(s2) ) puts("NO");
	else
	{
		l = strlen(s1);		

		memset(A1, 0, 1234);
		memset(A2, 0, 1234);
		for ( i = 0; i < l; ++i ) ++A1[s1[i] + 100];
		for ( i = 0; i < l; ++i ) ++A2[s2[i] + 100];
		qsort(A1, 400, sizeof(int), pIntCmp);
		qsort(A2, 400, sizeof(int), pIntCmp);

		int f = 1;

		for ( i = 0; i < 400; ++i )
			if ( A1[i] != A2[i] )
			{
				f = 0;
				break;
			}
		if ( f ) puts("YES"); else puts("NO");
	}

	fclose(stdout);
	return 0;
}