import java.util.Scanner;
/**
* HJ71 字符串通配符 - 中等
*/
public class HJ071 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String regx = sc.nextLine().toLowerCase();
String string = sc.nextLine().toLowerCase();
//做相应的替换
regx = regx.replaceAll("\\*{1,}", "[0-9A-Za-z]*");
regx = regx.replaceAll("\\?", "[0-9A-Za-z]{1}");
boolean result = string.matches(regx);
System.out.println(result);
}
sc.close();
}
}