import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto S = readln.split[0], T = readln.split[0];
	int[26] s_data, t_data;
	int[26] s_ord, t_ord;
	
	int ord = 1;
	foreach ( c; S ) {
		if (s_ord[c-'a'] == 0) {
			s_ord[c-'a'] = (ord++);
			s_data[ s_ord[c-'a']-1 ]++;
		}
		else s_data[ s_ord[c-'a']-1 ]++;
	}
	
	ord = 1;
	foreach ( c; T ) {
		if (t_ord[c-'a'] == 0) {
			t_ord[c-'a'] = (ord++);
			t_data[ t_ord[c-'a']-1 ]++;
		}
		else t_data[ t_ord[c-'a']-1 ]++;
	}
	
	writeln(s_data == t_data ? "Yes" : "No");
}