#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string s,t;
    cin >> s >> t;
    map<char,char> mp1,mp2;
    bool ok=true;
    rep(i,s.size()){
        if(mp1.count(s[i]) && mp1[s[i]]!=t[i])ok=false;
        if(mp2.count(t[i]) && mp2[t[i]]!=s[i])ok=false;
        mp1[s[i]]=t[i];
        mp2[t[i]]=s[i];
    }

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}