#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);		
		for ( i = 0; i < l; ++i ) A1[i] = s1[i];
		for ( i = 0; i < l; ++i ) A2[i] = s2[i];
		qsort(A1, l, sizeof(int), pIntCmp);
		qsort(A2, l, sizeof(int), pIntCmp);

		int f = 1;

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

	fclose(stdout);
	return 0;
}