import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String source = scan.nextLine();
source = source.toLowerCase();
String target = scan.nextLine();
target = target.toLowerCase();
System.out.println(isSame(source.toCharArray(),target.toCharArray()));
}
static boolean isSame(char[] source,char[] target){
int m = source.length;
int n = target.length;
boolean[][] dp = new boolean[n+1][m+1];
dp[0][0] = true;
for(int i = 0; i <= n; i++ ){
for(int j = 1; j <= m; j++){
if(source[j-1] == '*'){
if(i < 1){ // 处理第一行!
dp[i][j] = dp[i][j-1];
}else {
char c = target[i-1];
if(c == '.' || (c <= 'z' && c >= 'a') || (c <= '9' && c >= '0')){
dp[i][j] = dp[i-1][j] || dp[i][j-1];
}
}
}else {
if(i>0 && match(source[j-1],target[i-1])){
dp[i][j] = dp[i-1][j-1];
}
}
}
}
return dp[n][m];
}
static boolean match(char s,char t){
if(s == '?') return true;
return s == t;
}
}