// C - String Transformation
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S, T; cin>>S>>T;
	vector<int> st(26, -1), ts(26, -1);//st:S->T, ts:T->S
	int i;
	for(i=0; i<S.size(); ++i){
		int s = S[i]-'a', t = T[i]-'a';
		if(st[s] != ts[t]) break;
		st[s] = ts[t] = s;//s as common code
	}
	puts(i==S.size()? "Yes":"No");
}