import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            String regx = in.next();
            String str = in.next();
            regx = regx.toLowerCase();
            str = str.toLowerCase();
            regx = regx.replaceAll("\\*{2,}","\\*");
            regx = regx.replaceAll("\\?","[0-9a-z]{1}");
            regx = regx.replaceAll("\\*","[0-9a-z]{0,}");
            boolean b = str.matches(regx);
            System.out.println(b);
        }
    }
}