import java.util.HashSet;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        while(in.hasNext()){
             solution1(in);
            //  solution2(in); 
            //  solution3(in);
        }
    }

    /**
     * 正则: sub.matches(regex)
     * @param in
     */
    private static void solution1(Scanner in){
        String source = in.nextLine();
        String part = in.nextLine();

        String regex = part.replaceAll("\\?", "[0-1]");
        // String regex = part.replaceAll("\\?", "[01]{1}");

        HashSet<String> set = new HashSet<>();
        int len = source.length();
        int gap = part.length();
        String sub;
        for(int i=0; i+gap<=len; i++){
            sub = source.substring(i, i+gap);
            if(sub.matches(regex)){
                set.add(sub);
            }
        }

        System.out.println(set.size());
    }

    /**
     * 正则: matcher.matches()
     * @param in
     */
    private static void solution2(Scanner in){
        String source = in.nextLine();
        String part = in.nextLine();

        Pattern pattern = Pattern.compile(part.replaceAll("\\?", "[0-1]"));
        Matcher matcher;

        HashSet<String> set = new HashSet<>();
        int len = source.length();
        int gap = part.length();
        String sub;
        for(int i=0; i+gap<=len; i++){
            sub = source.substring(i, i+gap);
            matcher = pattern.matcher(sub);
            if(matcher.matches()){
                set.add(sub);
            }
        }

        System.out.println(set.size());
    }

    /**
     * 正则: matcher.find()
     * @param in
     */
    private static void solution3(Scanner in){
        String source = in.nextLine();
        String part = in.nextLine();

        Pattern pattern = Pattern.compile(part.replaceAll("\\?", "[0-1]"));
        Matcher matcher;

        HashSet<String> set = new HashSet<>();
        int len = source.length();
        int gap = part.length();
        String matched;
        for(int i=0; i+gap<=len; i++){
            matcher = pattern.matcher(source.substring(i, i+gap));
            if(matcher.find()){
                matched = matcher.group();
                set.add(matched);
            }
        }

        System.out.println(set.size());
    }
}