#include<bits/stdc++.h>
using namespace std;
int main(){
    string ans = "Yes";
  	string s, t;
  	map<char, char> s2t, t2s;
	cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
      if(s2t.count(s[i]) > 0 && s2t[s[i]] != t[i]){
        ans = "No";
      } else if(t2s.count(t[i]) > 0 && t2s[t[i]] != s[i]){
        ans = "No";
      }else{
        s2t[s[i]] = t[i];
        t2s[t[i]] = s[i];
      }
    }
  	cout << ans << endl;
  
}