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

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

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