#include <iostream>
#include <vector>
using namespace std;
// 动态规划,str包含?或*
int isMatch(string str, string s){
    vector<vector<int>> dp(str.size()+1, vector<int>(s.size()+1,0));
    dp[0][0] = 1;
    for (int i = 1; i <= str.size(); ++i){
        dp[i][0] = dp[i-1][0] && (str[i-1] == '*');
        for (int j = 1; j <= s.size(); ++j){
            if (str[i-1] == '*'){
                dp[i][j] = dp[i-1][j] || dp[i][j-1];
            }else if (isdigit(s[j-1])){
                dp[i][j] = dp[i-1][j-1] && ((str[i-1] == '?') || (str[i-1] == s[j-1]));}else if (isalpha(s[j-1])){
                    dp[i][j] = dp[i-1][j-1] && (str[i-1] == '?'|| tolower(str[i-1]) == tolower(s[j-1]));}else {
                        dp[i][j] = dp[i-1][j-1] && (str[i-1] == s[j-1]);
                    }
        }
    }
    return dp[str.size()][s.size()];
}
int main() {
    string str, s;
    while (cin >> str >> s) { 
        if (isMatch(str, s)){
            cout << "true" << endl;
        }else {
            cout << "false" << endl;
        }
    }
    return 0;
}