#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	set<char>ar[26],arr[26];
	for(int i=0;i<a.size();i++){
		ar[(a[i]-'a')].insert(b[i]);
		arr[(b[i]-'a')].insert(a[i]);
	}
	for(int i=0;i<26;i++){
		if(ar[i].size()>1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=0;i<26;i++){
		if(arr[i].size()>1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}