#include <bits/stdc++.h>
using namespace std;
vector<int> F(string s) {
vector<int> res;
int cnt = 1;
for(int i = 1; i < (int)s.size(); i++) {
if (s[i] == s[i - 1]) {
cnt++;
} else {
res.push_back(cnt);
cnt = 1;
}
}
res.push_back(cnt);
return res;
}
int main()
{
string s, t;
cin >> s >> t;
if (s[0] != t[0]) {
cout << "no" << endl;
return 0;
}
vector<int> A = F(s);
vector<int> B = F(t);
if (A.size() != B.size()) {
cout << "no" << endl;
return 0;
}
if (A[0] != B[0] || A.back() != B.back()) {
cout << "no" << endl;
return 0;
}
for(int i = 1; i < (int)A.size() - 1; i++) {
if (A[i] < B[i] || A[i] % 2 != B[i] % 2) {
cout << "no" << endl;
return 0;
}
}
cout << "yes" << endl;
return 0;
}