#include <bits/stdc++.h>
using namespace std;

void calc(string& S) {
	map<char, char> to;
	char t = 'a';
	for (auto& c : S) to.count(c) ? c = to[c] : c = to[c] = t++;
}

int main()
{
	string S, T;
	cin >> S >> T;
	calc(S); calc(T);
	puts(S == T ? "Yes" : "No");
	return 0;
}
