var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var s = input[0];
	var t = input[1];
	var n = s.length;
	var x = [];
	var y = [];
	var a,b;
	var c,d;
	var e,f;
	for(var i = 0; i < n; i++){
		a = x.indexOf(s[i]);
		b = y.indexOf(t[i]);
		if(a>-1){
			if(b>-1){
				if(a !== b){
					console.log('No');
					return 0;
				}
			}else{
				console.log('No');
				return 0;
			}
		}else{
			if(b>-1){
				console.log('No');
				return 0;
			}else{
				c = s[i];
				d = t[i];
				x.push(c);
				y.push(d);
				for(var j = i+1; j < n; j++){
					e = s[j]===c? 1: -1;
					f = t[j]===d? 1: -1;
					if(e*f !== 1){
						console.log('No');
						return 0;
					}
				}
			}
		}
	}
	console.log('Yes');
	return 0;
}