#include <bits/stdc++.h>
using namespace std;


string c, d;
bool strmatch(int i, int j){
    if (i >= c.size() and j >= d.size()) return true;
    if (i >= c.size() or j >= d.size()) return false;
    if (c[i]=='?'){
        if (isalpha(d[j]) or isdigit(d[j])) return strmatch(i+1, j+1);
        return false;
    }
    else if (c[i]=='*'){
        if (isalpha(d[j]) or isdigit(d[j])) return strmatch(i+1, j) || strmatch(i, j+1) || strmatch(i+1, j+1);
        else return strmatch(i+1, j);
    }
    else {
        if (c[i] != d[j]) return false;
        return strmatch(i+1, j+1);
    }
}


int main(){
    string a, b;
    cin >> a >> b;
    bool hasstar = false;
    for(int i = 0; i < a.size(); i++){
        if (!hasstar or a[i] != '*') c.push_back(tolower(a[i]));
        if (a[i] == '*') hasstar=true;
        if (a[i] != '*') hasstar=false;
    }
    for(int i = 0; i < b.size(); i++) d.push_back(tolower(b[i]));
    // cout << c << " " << d << endl;
    if (strmatch(0, 0)) cout << "true";
    else cout << "false";
    return 0;
}