#include <cctype>
#include <iostream>
using namespace std;
bool match(const char* s, const char* p){
if((*p=='\0')&&(*s=='\0')){
return true;
}
if((*p=='\0')||(*s=='\0')){
return false;
}
if(*p == '?'){
if(!isdigit(*s)&&!isalpha(*s))
return false;
return match(s+1,p+1);
}else if(*p == '*'){
while(*p == '*'){
p++;
}
p--;
//遇到*号,匹配0个(str+1,str1不用动),匹配1个(str和str1都往前移动1位),匹配多个(str不用动,str+1)
return match(s,p+1)||match(s+1,p+1)||match(s+1, p);
}else if(tolower(*p) == tolower(*s)){
return match(s+1,p+1);
}
return false;
}
int main() {
string p,s;
getline(cin,p);
getline(cin,s);
bool res = match(s.c_str(),p.c_str());
if(res)
cout<<"true"<<endl;
else
cout<<"false"<<endl;
return 0;
}
// 64 位输出请用 printf("%lld")