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

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