#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

bool can_make_str(std::string S, std::string T) {
	int len = S.length();
	int sind1 = -1;
	int tind1 = -1;
	int sind2 = -1;
	int tind2 = -1;
	bool smode = true;
	bool sfind = false;
	bool tfind = false;
	bool sseq = true;
	bool tseq = true;

	for (int n = 0; n < len; n++) {
		if ( smode ) {
			for (int i = sind1+1; i < len && !sfind && sseq; i++) {
				if ( S[i] == S[n] ) {
					sfind = true;
					sind1 = i;
				}
			}
			for (int i = tind1+1; i < len && !tfind && tseq; i++) {
				if ( T[i] == S[n] ) {
					tfind = true;
					tind1 = i;
				}
			}
			smode = false;
		}
		else {
			for (int i = sind2+1; i < len && !tfind && tseq; i++) {
				if ( S[i] == S[n] ) {
					tfind = true;
					sind2 = i;
				}
			}
			for (int i = tind2+1; i < len && !sfind && sseq; i++) {
				if ( T[i] == S[n] ) {
					sfind = true;
					tind2 = i;
				}
			}
			smode = true;
		}
		if ( sfind ) {
			sfind = false;
		}
		else {
			sseq = false;
		}
		if ( tfind ) {
			tfind = false;
		}
		else {
			tseq = false;
		}
	}
	return ( sseq || tseq );
}

int main(void) {
	std::string S,T;
	cin >> S >> T;

	if ( can_make_str(S,T) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}