#include<iostream>
#include<string>
using namespace std;

int main() {
	string s, t; cin >> s >> t;

	int cs[26] = {}, ct[26] = {};
	for (int i = 0; i < s.size(); i++) {
		cs[s[i] - 'a']++;
		ct[t[i] - 'a']++;
		if (cs[s[i] - 'a'] != ct[t[i] - 'a']) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}