import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
	auto s = chomp(readln());
	auto t = chomp(readln());

	int[] history;
	history.length = 1000;
	fill(history, -1);
	bool isYes = true;
	char last1 = s[0], last2 = t[0];
	foreach (i, e1; s)
	{
		char e2 = t[i];
		if (e1 == last1 && e2 != last2)
		{
			isYes = false;
			break;
		}
		if (e1 != e2)
		{
			if (history[e1] != -1 && history[e1] != e2)
			{
				isYes = false;
				break;
			}
			history[e1] = e2;
		}
		last1 = e1;
		last2 = e2;
	}
	
	writeln(isYes ? "Yes" : "No");
	stdout.flush();
}