#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define maxn 105
int cmp(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
}
int main()
{
char a[maxn], b[maxn];
while(scanf("%s%s", a, b) != EOF)
{
int lenn = strlen(a);
int lenm = strlen(b);
if(lenn != lenm)
{
printf("NO\n");
continue;
}
int na[26], nb[26];
memset(na, 0, sizeof(na));
memset(nb, 0, sizeof(nb));
for(int i = 0; i < 26; i++)
for(int j = 0; j < lenn; j++)
{
int n = a[j]-'A';
int m = b[j]-'A';
na[n]++;
nb[m]++;
}
qsort(na, 26, sizeof(int), cmp);
qsort(nb, 26, sizeof(int), cmp);
bool flag = true;
for(int i = 0; i < 26; i++)
{
if(na[i] != nb[i])
{
printf("NO\n");
flag = false;
break;
}
}
if(flag)
printf("YES\n");
}
return 0;
}