#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    vector<int> c1(26,0),c2(26,0);
    for(int i = 0; i < s.size(); i++){
        c1[s[i]-'a']++;
        c2[t[i]-'a']++;
    }
    sort(c1.begin(),c1.end());
    sort(c2.begin(),c2.end());
    if(c1==c2)
        cout<<"Yes";
    else
        cout<<"No";
}
