#include <bits/stdc++.h> 
using namespace std;

string str1 ,str2;
int a[30] ,b[30];

int main(){
    cin >> str1 >> str2;
    for(int i = 0;i < str1.size(); i++)
        a[str1[i] - 'a']++ ,b[str2[i] - 'a']++;
    sort(a ,a + 26),   sort(b ,b + 26);
    for(int i = 0; i < 26; i++)
        if(a[i] != b[i])
            return cout << "No", 0;
    cout << "Yes";
    return 0;
}


