#include <cwctype>
#include <iostream>
#include <vector>
using namespace std;
// 参考网友算法,使用递归遍历
// 小写统一转大写,合并连续的*,通配符仅匹配数字跟字母
//数字或者字母
bool IsDC(char c) {
return (c >= 'A' && c <='Z') || (c >= '0' && c <= '9');
}
bool Match(const char* s, const char* p) {
if(*s == '\0' && *p =='\0') {
return true;
}
if(*s == '\0' || *p =='\0') {
return false;
}
if(*s == '?') {
if(!IsDC(*p)) {
return false;
} else {
return Match(s+1, p+1);
}
}
if(*s == '*') {
if(IsDC(*p)) {
return Match(s+1, p) || Match(s, p+1) || Match(s+1, p+1);
} else {
return Match(s+1, p);
}
}
if(*s == *p) {
return Match(s+1, p+1);
} else {
return false;
}
}
int main() {
string s, p, t;
cin >> t >> p;
const int off = 'a' - 'A';
for(auto v : {&t,&p}) {
for(auto& c : *v) {
if(c >= 'a' && c <= 'z') {
c -= off;
}
}
}
char last = 0;
for(auto c : t) {
if(c == '*') {
if(last != c) {
s.push_back(c);
}
}else{
s.push_back(c);
}
last = c;
}
cout << (Match(s.c_str(),p.c_str())?"true":"false") << endl;
}
// 64 位输出请用 printf("%lld")