#include <algorithm>
#include <iostream>
#include <math.h>
#include <fstream>
#include <cstdlib>
#include <vector>
#include <map>
#include <tuple>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <regex>
using namespace std;
int main() {
string word, mask;
cin >> word >> mask;
for (size_t i = 0; i < mask.size(); ++i) {
if (mask[i] == '?') {
mask[i] = '.';
}
if (mask[i] == '*') {
mask[i] = '.';
mask.insert(i + 1, "*");
}
}
mask += "$";
regex reg = mask; //Вот здесь ошибка
regex_match(word, reg) ? cout << "YES" : cout << "NO";
system("pause");
}