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

int cnt1[26], cnt2[26];

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

	for (auto i : s) cnt1[i - 'a']++;
	for (auto i : t) cnt2[i - 'a']++;

	sort(cnt1, cnt1 + 26); sort(cnt2, cnt2 + 26);

	for (int i = 0;i < 26;i++) {
		if (cnt1[i] != cnt2[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
    return 0;
}

