#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

char a[105] = {0};
char b[105] = {0};
int c[26] = {0};
int d[26] = {0};

int main()
{
    scanf("%s%s",a,b);
    int la = strlen(a);
    int lb = strlen(b);
    for(int i = 0; i < la; i++)
    {
        c[a[i] - 'A']++;
    }
    for(int i = 0; i < lb; i++)
    {
        d[b[i] - 'A']++;
    }
//    for(int i = 0; i < 26; i++)
//    {
//        printf("%d",c[i]);
//    }
//    printf("\n");
//    for(int i = 0; i < 26; i++)
//    {
//        printf("%d",d[i]);
//    }
//    printf("\n");
    sort(c, c + 26);//一一映射就是可以随便映射 前一位前两位后一位甚至本身
    sort(d, d + 26);//所以只要数字对的上就可以了 内容不重要
    bool flag = true;
    for(int i = 0; i < 26; i++)
    {
        if(c[i] != d[i])
        {
            flag = false;
            break;
        }
    }
    if(flag)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
//    for(int i = 0; i < 26; i++)
//    {
//        printf("%d",c[i]);
//    }
//    printf("\n");
//    for(int i = 0; i < 26; i++)
//    {
//        printf("%d",d[i]);
//    }
//    printf("\n");
    return 0;
}