function main(arg) {
	arg  = arg.split("\n")
	var s = arg[0]
	var t = arg[1]

	while (1) {
		if (s === "") {
			break
		} 

		s = s.split(s[0]).join("")
		t = t.split(t[0]).join("")

		if (s.length !== t.length) {
			console.log('No')
			return;
		}
	}
	console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
