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

int main() {
	string s, t;
	cin >> s >> t;
	vector<int> S(26, 0), T(26, 0);
	for (int i = 0; i < s.size(); i++)
		S[s[i] - 97]++;
	for (int i = 0; i < t.size(); i++)
		T[t[i] - 97]++;
	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	if (S == T)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}
